开发者

How to fetch custom Google Search results by simple html dom parser?

I have a custom Google Search included on a html page. like

http://www.******.com/search.htm?cx=partner-pub--00000000000-c77&cof=FORID%3A10&ie=ISO-8ds3-1&q=software&sa=Search&siteurl=www.******.com%2#1342

When I am using same url in browser I get results. I want 开发者_Python百科to call it by simple dom html parser then it is returning blank.

Or how can I fetch Google custom search results with Google partner ID via Simple HTML DOM parser so I can get analytics for searches done.


You can't, they have safeguards against that and it is against their terms of use. Excerpt from the Web Search API Terms of Service:

[...]By way of example, and not as a limitation, You agree that when using the Service, You will not, and will not permit users or other third parties to:

[...] use any robot, spider, site search/retrieval application, or other device to retrieve or index any portion of Google Search Results or to collect information about users for any unauthorized purpose;


I do not know about the custom google search, but with the normal one I got all results, by simply applying the

url[?]q=([^&]+)&

regex to all hrefs.

edit: taking the match in the parentheses to get the url, ofc.

(Did not notice that this was an old question that was edited (for what?), but perhaps it is still useful for someone)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜