用爬虫获取百度热搜
import requests
from bs4 import BeautifulSoup
from openpyxl import Workbook
def getHtml():
# 获取网页源码
headers={
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 SLBrowser/7.0.0.5211 SLBChan/103"}
html=requests.get("https://top.baidu.com/board?tab=realtime",headers=headers)
html.encoding=html.apparent_encoding #获取原本网站发个你的编码然后堆上去
return html.text
# 处理源码想要的数据
def getContent():</