【发布时间】:2017-06-19 05:43:05
【问题描述】:
我需要在 Google 中搜索后解析带有结果的链接。
当我尝试查看页面代码和Ctrl + U 时,我找不到带有链接的元素,这是我想要的。
但是当我看到元素代码时
Ctrl + Shift + I 我可以看到我应该解析什么元素来获取链接。
我用代码
url = 'https://www.google.ru/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=' + str(query)
html = requests.get(url).content
soup = BeautifulSoup(html, 'html.parser')
links = soup.findAll('cite')
但它返回空列表,因为没有这个元素。
我认为返回requests.get(url).content 的html-code 不完整,所以我无法获取这些元素。
我尝试使用google.search,但它返回错误it isn't used now.
有什么方法可以在谷歌中获取搜索链接?
【问题讨论】:
-
试试
html = requests.get(url).text -
@MithileshKumar 它没有帮助
-
可以打印显示
requests.get(url).text -
@MithileshKumar 它以
<!DOCTYPE doctype html> <html itemscope="" itemtype="http://schema.org/WebPage" lang="ru"><head><meta content="Поиск информации в интернете: веб страницы, картинки, видео и многое другое." name="description"><meta content="noodp" name="robots"><meta content="text/html; charset=utf-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/googleg_standard_color_128dp.png" itemprop="image"><title>Google</title><script>(function(){window.google=开头 -
上面的“引用”是什么?
标签: python python-requests google-search