谷歌搜索库:googlesearch-python

谷歌搜索

googlesearch是一个Python库,可轻松爬取Google搜索结果。googlesearch使用requests和

BeautifulSoup4抓取Google。

安装

要安装,请运行以下命令:

python3 -m pip install googlesearch-python
或者
pip3 install googlesearch-python
用法

要获取搜索字词的结果,只需使用googlesearch中的搜索功能。例如,要在Google中获取“ 高效码农”的结果,只需运行以下程序:

from googlesearch import search
import pprint

list = search("高效码农")
pprint.pprint(list)

打印结果:

['https://www.xugj520.cn/',
 'https://blog.csdn.net/Java_supermanNO1/article/details/104536476',
 'https://weekly.manong.io/issues/295',
 'https://item.jd.com/12481316.html',
 'https://zhuanlan.zhihu.com/p/29481305',
 'https://zhuanlan.zhihu.com/p/102597965',
 'https://my.oschina.net/u/1189098',
 'https://www.codercto.com/a/98794.html',
 'https://www.cnblogs.com/huang0925/p/3612741.html',
 'https://www.jiqizhixin.com/users/0d71c15b-b934-482a-aadc-5f5cf63afd60']
其他选项

googlesearch支持其他一些选项。默认情况下,googlesearch返回10个结果。这可以更改。例如,要在Google上获得100个结果,请运行以下程序。

from googlesearch import search
import pprint

list = search("高效码农",  num_results=100)

pprint.pprint(list)

此外,您可以更改Google搜索的语言。例如,要获取法语结果,请运行以下程序:

list = search("高效码农",  num_results=100, lang='fr')
完整API:
googlesearch.search(str: term, int: num_results=10, str: lang="en") -> list
代理设置

代理设置请移步:https://www.xugj520.cn/archives/googlesearch.html

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值