简体   繁体   English

Google自定义搜索API C#

[英]google custom search api c#

I have ac# webservice that uses WebClient.Downloadstring(MYURL) to get a Google page. 我有一个使用WebClient.Downloadstring(MYURL)来获取Google页面的ac#Web服务。

MYURL is equal to: MYURL等于:

http://www.google.co.uk/search?q=mystringtosearch&as_qdr=all&num=100&start=0 http://www.google.co.uk/search?q=mystringtosearch&as_qdr=all&num=100&start=0

It was working fine until i got 503 errors from Google for being a bot. 直到我收到来自Google的503错误提示,然后一切正常为止。 I then got sent here: 然后我被发送到这里:

https://developers.google.com/custom-search/v1/overview https://developers.google.com/custom-search/v1/overview

and got a key. 拿到了钥匙 Now it says all I need to do is add the &key parameter. 现在它说我要做的就是添加&key参数。 However, when I have this as MYURL i still get a 503 但是,当我将其作为MYURL时,我仍然得到503

http://www.google.co.uk/search?q=mystringtosearch&key=1234567890&as_qdr=all&num=100&start=0 http://www.google.co.uk/search?q=mystringtosearch&key=1234567890&as_qdr=all&num=100&start=0

The Google API console says that I haven't done any searches, so I know I haven't gone over my quota. Google API控制台说我没有做任何搜索,所以我知道我没有超出配额。

What's going on? 这是怎么回事?

您需要在URL中包括您的自定义搜索引擎ID。如文档所述,这就是cx参数的作用。

Are you sure you are using correct url? 您确定使用正确的网址吗? Your my url is not customsearch api's url? 您的我的网址不是customsearch api的网址吗?

If you look at documantation of custom search which is this: https://developers.google.com/custom-search/v1/using_rest?hl=tr 如果您查看的是自定义搜索的文档,则为: https : //developers.google.com/custom-search/v1/using_rest?hl= tr

yuo can retrieve results for a particular search by sending an HTTP GET request to its URI. yuo可以通过向其URI发送HTTP GET请求来检索特定搜索的结果。 The URI for a search has the following format: 搜索的URI具有以下格式:

https://www.googleapis.com/customsearch/v1?parameters https://www.googleapis.com/customsearch/v1?parameters

documantation has more info documantation有更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM