我正在开展一个项目,我想整合Google网站管理员工具Api。我有一个webmastertool帐户,我想构建一个程序,每天将动态地将我的网站的所有信息提取到Excel工作表中。我搜索过但没有找到任何好的文档来在C#中实现API。
谁能告诉我在哪里可以找到更好/更多关于它的文档?
答案 0 :(得分:1)
您当然可以从使用此开始:http://code.google.com/p/google-gdata/
并使用一些代码:
class Program
{
private static int lastIndex = 0;
static int DumpCrawlErrors(int startFrom)
{
WebmasterToolsService service = new WebmasterToolsService("exampleCo-exampleApp-1");
service.setUserCredentials("myusername", "mypassword");
string url = HttpUtility.UrlEncode("http://example.com");
string slug = Utilities.EncodeSlugHeader("https://www.google.com/webmasters/tools/feeds/" + url + "/crawlissues/?start-index=" + startFrom + "&max-results=100");
CrawlIssuesQuery feedQuery = new CrawlIssuesQuery(slug);
CrawlIssuesFeed feed = service.Query(feedQuery);
StringBuilder results = new StringBuilder();
foreach (CrawlIssuesEntry crawlIssuesEntry in feed.Entries)
{
string crawlUrl = ((XmlExtension)crawlIssuesEntry.ExtensionElements[2]).Node.InnerText;
if (crawlIssuesEntry.IssueType == "not-found")
{
results.AppendLine(string.Format("{0}\t{1}\t{2}\t{3}", crawlUrl, crawlIssuesEntry.IssueType, crawlIssuesEntry.IssueDetail, crawlIssuesEntry.LinkedFrom));
}
}
System.IO.File.AppendAllText("result.log", results.ToString());
return feed.Entries.Count;
}
static void Main(string[] args)
{
lastIndex = 0;
int numberOfEntriesAdded = 0;
do
{
numberOfEntriesAdded = DumpCrawlErrors(lastIndex + 1);
lastIndex += numberOfEntriesAdded;
} while (numberOfEntriesAdded == 100);
}
}
可以在此处找到完整的Java参考:https://developers.google.com/webmaster-tools/docs/2.0/developers_guide_java
我知道这不是C#,但它会给你一个很好的起点。