如何在python中获取Google的url摘录 [英] How to get Google like url excerpts in python

查看:55
本文介绍了如何在python中获取Google的url摘录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了这样的代码:

#pip3 install google 
from googlesearch import search

query = 'java'


for i in search(query,        # The query you want to run
                tld = 'com',  # The top level domain
                lang = 'en',  # The language
                num = 10,     # Number of results per page
                start = 0,    # First result to retrieve
                stop = None,  # Last result to retrieve
                pause = 0,  # Lapse between HTTP requests
                safe = 'high'

               ):
    print(i)

在上面的

中,我只是获得了url链接.我该如何获取每个网址的节录之类的Google.就像所附的

in the above, I am simply getting the url link. How can I get google like excerpts for each url. Like the attached

推荐答案

如果您在某些网络上的python上使用 requests 模块,我认为无法使用BUT包来实现抓取库( beautifulsoup )中,您可以使用HTML标记获取这些描述(<元名称=描述" content ="Google描述"> )

I don't think it is possible to do it with the package BUT if you use the requests module on python with some web scraping libraries (beautifulsoup) you can get those descriptions with the HTML tag (<meta name="description" content="google description">)

这篇关于如何在python中获取Google的url摘录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆