在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/Python/ python 怎么取谷歌搜索的源代碼呢?

python 怎么取谷歌搜索的源代碼呢?

已翻墻,用IE或火狐可以正常搜索谷歌。

import requests

def res(pageurl):
    s = requests.get(pageurl)
    print(s)



if __name__ == '__main__':
    res('http://www.google.com.hk/search?safe=strict&source=hp&q=qqq&oq=qqq')
    

運(yùn)行提示:

requests.exceptions.ConnectionError: HTTPConnectionPool(host='www.google.com.hk', port=80): Max retries exceeded with url: /search?safe=strict&source=hp&q=qqq&oq=qqq (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection object at 0x0000000004AD50B8>: Failed to establish a new connection: [WinError 10060] 由于連接方在一段時(shí)間后沒(méi)有正確答復(fù)或連接的主機(jī)沒(méi)有反應(yīng),連接嘗試失敗。',))

故求助,估計(jì)還會(huì)遇到協(xié)議頭的問(wèn)題,若有解決辦法盼告知~

回答
編輯回答
薔薇花

你本機(jī)翻墻,不代表你使用requests用到了代理,你應(yīng)該使用能爬梯的代理ip訪問(wèn)

2017年7月24日 11:57
編輯回答
脾氣硬
proxies = { "http": "http://10.10.1.10:3128", "https": "http://10.10.1.10:1080", }   //改成你的代理服務(wù)器
requests.get("http://example.org", proxies=proxies)  
2017年7月30日 20:28