好的,我已经缩小了使用python返回谷歌搜索结果的问题。这不是搜索或使用API的问题。这是如何用PYTHON阅读结果的问题。
现在,请某人,任何人,向我展示只会像浏览器一样打印网页结果的代码(单词和文字,我甚至不关心它是否包含所有的html脚本..只要它确实包含网页上的文字和网址......)
所以,这是我正在尝试将结果页面加载到python中的URL:
https://www.google.com/search?tbs=sbi:AMhZZiv5l6a7Y6F6PDOH62elkfPDoGserB70if-j-hUzcB30VB0IOmADts8UKGKr8dRpfXlU3VVMA-TOTbqYHXl4weH3A9fyYrpubR8zXlxSR_1jvfMbrz3nkeHCxTYgoSR34KQmSGYlV6NTXP1ag7QumbRdKqqlWsg6RwZh-v0ogPxPqEn3a_1dWgX_1SisyEKKRAD6K-Zge6NA-i54t0-sNR0lINQ96d_1YfN9aw7KQlZp2bzcw97h8Ckb1XR0-t9B_1WbdTv1A1WDWttcfUMGI3Y5zIgwHoQPpNM6x9zbhgemlabzqbMJzGUezF3KT1KG6AWCRdnlaMWbMb_1m_1T-A_1EHnqDm0Wt3wILSIAHdi_1sfMjSyDN2wNjeFxJ3LsGAZN-sx24MIlOz7nT4wOmXtEeECRIBvuSS4iH7SbeC5gf3Iac41He1k7w_1NTt1_1-R8TsdryCxs0Pysu2DA7WuBMLqHcrovkgoCZLGdXbuWx_1nY4nu39VqBiBIpQOPMfPkTknT_1M0nVgO_1ppmSgikY3fKbIByzz8FOJgUBb0Nu2p_1Zoo-XRprDgOb-UVubVk-CsGwN2dF_1I81J6vFOUI_14bS5nYjZaEHx6-Lxxij84Za-fL5G4XCnZc-0LPyzAmbvckao55OXqMUBgZbx9e7VRg2jLYaxrzFYtiIUqjG9-IqXoi4ZhWTxZuk_1sUkXFO3NNdeuQ_1Ise9lisoBCLyfpBz1Qnh1dvP_1zb0Cor2Vbp9gTr9VjuOxTHjglWJSntw4OLt6jCfdZOve-iuEdh9V5fSPk41WidEfkWTxMo1dfbPxShrGFGF1oEdd6soYCJnp6YjnXYEYGOEMUgdBUXdB1bFbmBop5WU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09hQlgxeHlwVmZiUXh2eDFRdDlKS1M1UVVCRjQzT3VCZWwtb3hieEVyUVVxdW12UWxMbTRIdEJrVGlXdjJZZHBFQjNkSm1TamdIQzdQUkh0aWY2Z0FCS3hrQlJZaFJhejQ5NkZzd1VoS2s5Qm1FR01YQ1djUk9nQ2kySm94b0tVSW5YNnNtb1hvVTVOWXhHeDZ2YWZNbURDemZfMWlXd3p2XzFTUlQwN1hXUnNTWWZZNU9ROUFSbDNzbUpQUFpybVNvb2ZkRWRnTXBMc3pUTS1aYWdlQVotaS1SUDViNHZQWHk0NlhjU1dvdl8xNFFYSTd2c3hVMmJPOVBGUzVfMWZpUklrNThBbFNMZG9uSTB1R2JqQjZaa2tRJmFtcDt1c2VyLWFnZW50PU1vemlsbGEvNS4wJTIwKFdpbmRvd3MlMjBOVCUyMDUuMTslMjBydjo2LjAuMiklMjBHZWNrby8yMDEwMDEwMSUyMEZpcmVmb3gvNi4wLjImYW1wO2Nvbm5lY3Rpb249a2VlcC1hbGl2ZQ%3D%3D&f=norefer
所以很明显,python CAN会返回此页面的搜索结果,我只是无法弄明白。
现在,我是新手,所以我正在学习,但到目前为止,我得到的唯一答案是我应该使用谷歌API,或者我应该使用非python方法(包括spynner或selenium,它们是不是标准的python库..)肯定有人在这里知道如何做到这一点。
以下是我尝试的代码:
import urllib2
req=urllib2.Request(link)
response=urllib2.urlopen(req)
page=response.read()
print(page)
#or thru hidemyass.com:
req=urllib2.Request('http://hidemyass.com/',link)
response=urllib2.urlopen(req)
page=response.read()
print(page)
# BeautifulSoup :
from BeautifulSoup import BeautifulSoup
soup=BeautifulSoup(page)
print(soup)
它都不起作用:(我没有得到结果页面,我没有得到“对此图像的最佳猜测”文本..我弄得一团糟:(