如何使用python在谷歌搜索中提取描述?

时间:2017-10-09 08:30:08

标签: python html google-search

我想从谷歌搜索中提取描述, 现在我有了这段代码:

from urlparse import urlparse, parse_qs
import urllib

from lxml.html import fromstring
from requests import get


    url='https://www.google.com/search?q=Gotham'
    raw = get(url).text
    pg = fromstring(raw)
    v=[]
    for result in pg.cssselect(".r a"):
      url = result.get("href")
      if url.startswith("/url?"):
         url = parse_qs(urlparse(url).query)['q']
      print url[0]

提取与搜索相关的网址,如何提取网址下显示的说明?

0 个答案:

没有答案