google

package
v1.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateSitemap

func GenerateSitemap(urls []string, filename string) error

GenerateSitemap 生成网站地图

func GenerateSitemapIndex

func GenerateSitemapIndex(sitemaps []string, filename string) error

GenerateSitemapIndex 生成网站地图索引

func PingSearchEngines

func PingSearchEngines(sitemapURL string) error

PingSearchEngines 通知搜索引擎网站地图更新

func SplitSitemap

func SplitSitemap(urls []string, maxURLsPerSitemap int, baseURL string) ([]string, error)

SplitSitemap 将大量URL分割成多个网站地图

Types

type Client

type Client struct {
	SiteURL string
	// contains filtered or unexported fields
}

Client Google Search Console API客户端

func NewClient

func NewClient(config *Config) (*Client, error)

NewClient 创建新的客户端

func (*Client) BatchInspectURL

func (c *Client) BatchInspectURL(urls []string, callback func(url string, result *URLInspectionResult, err error))

BatchInspectURL 批量检查URL状态

func (*Client) BatchPublishURLs

func (c *Client) BatchPublishURLs(urls []string, urlType string, callback func(url string, success bool, err error))

BatchPublishURLs 批量提交URL到Google索引

func (*Client) GetSearchAnalytics

func (c *Client) GetSearchAnalytics(startDate, endDate string) (*searchconsole.SearchAnalyticsQueryResponse, error)

GetSearchAnalytics 获取搜索分析数据

func (*Client) GetSites

func (c *Client) GetSites() ([]*searchconsole.WmxSite, error)

GetSites 获取已验证的网站列表

func (*Client) GetURLNotificationStatus

func (c *Client) GetURLNotificationStatus(url string) (*indexing.UrlNotificationMetadata, error)

GetURLNotificationStatus 获取URL通知状态

func (*Client) InspectURL

func (c *Client) InspectURL(url string) (*URLInspectionResult, error)

InspectURL 检查URL索引状态

func (*Client) PublishURL

func (c *Client) PublishURL(url string, urlType string) error

PublishURL 提交URL到Google索引

func (*Client) SubmitSitemap

func (c *Client) SubmitSitemap(sitemapURL string) error

SubmitSitemap 提交网站地图

type Config

type Config struct {
	CredentialsFile string `json:"credentials_file"`
	SiteURL         string `json:"site_url"`
	TokenFile       string `json:"token_file"`
}

Config 配置信息

type Sitemap

type Sitemap struct {
	XMLName xml.Name     `xml:"urlset"`
	Xmlns   string       `xml:"xmlns,attr"`
	URLs    []SitemapURL `xml:"url"`
}

Sitemap 网站地图结构

type SitemapIndex

type SitemapIndex struct {
	XMLName  xml.Name     `xml:"sitemapindex"`
	Xmlns    string       `xml:"xmlns,attr"`
	Sitemaps []SitemapRef `xml:"sitemap"`
}

SitemapIndex 网站地图索引

type SitemapRef

type SitemapRef struct {
	Loc     string `xml:"loc"`
	LastMod string `xml:"lastmod,omitempty"`
}

SitemapRef 网站地图引用

type SitemapURL

type SitemapURL struct {
	Loc        string `xml:"loc"`
	LastMod    string `xml:"lastmod,omitempty"`
	ChangeFreq string `xml:"changefreq,omitempty"`
	Priority   string `xml:"priority,omitempty"`
}

SitemapURL 网站地图URL项

type URLInspectionRequest

type URLInspectionRequest struct {
	InspectionURL string `json:"inspectionUrl"`
	SiteURL       string `json:"siteUrl"`
	LanguageCode  string `json:"languageCode"`
}

URLInspectionRequest URL检查请求

type URLInspectionResult

type URLInspectionResult struct {
	IndexStatusResult struct {
		IndexingState string `json:"indexingState"`
		LastCrawled   string `json:"lastCrawled"`
		CrawlErrors   []struct {
			ErrorCode string `json:"errorCode"`
		} `json:"crawlErrors"`
	} `json:"indexStatusResult"`
	MobileUsabilityResult struct {
		MobileFriendly bool `json:"mobileFriendly"`
	} `json:"mobileUsabilityResult"`
	RichResultsResult struct {
		Detected struct {
			Items []struct {
				RichResultType string `json:"richResultType"`
			} `json:"items"`
		} `json:"detected"`
	} `json:"richResultsResult"`
}

URLInspectionResult URL检查结果

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL