试图在谷歌搜索结果中爬行。这段代码可以很好地与所有其他网站,我尝试过,但没有与谷歌合作。它返回一个空列表。在
from BeautifulSoup import BeautifulSoup
import requests
def googlecrawler(search_term):
url="https://www.google.co.in/?gfe_rd=cr&ei=UVSeVZazLozC8gfU3oD4DQ&gws_rd=ssl#q="+search_term
junk_code=requests.get(url)
ok_code=junk_code.text
good_code=BeautifulSoup(ok_code)
best_code=good_code.findAll('h3',{'class':'r'})
print best_code
googlecrawler("healthkart")
它应该返回这样的值。在
^{pr2}$
看着}。这就是为什么你的代码返回一个空列表。在
good_code
我根本看不到h3
或{您的代码本身没有问题,但是您要搜索的内容并不存在。在
你想回来什么?在
相关问题 更多 >
编程相关推荐