以python打印Google搜索结果

问题描述 投票:0回答:1

[我如何打印Google搜索结果,例如:

enter image description here

当用户输入搜索程序的查询时必须打印搜索结果

python google-search
1个回答
0
投票

这可以通过使用Bs4(beautifulSoup4)和请求来完成

如果您只想打印那些框式遮阳篷,则需要在html中使用该项目的标签和ID进行刮擦

这里是您的代码的基本模板

from bs4 import BeautifulSoup
import requests
import lxml #just incase you know how to parse with that library

source = requests.get("your google link here")
soup = BeautifulSoup(source.text, 'html.parser')
parsed = soup.findAll("your tag here") #you can add ID's to this just look at the html.parser documentation

希望这有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.