标签:strong bilibili app 程序包 odi python爬虫 执行 with open input
管理程序包,执行安装requests包命令
pip install requests
import requests
import requests
if __name__ == "__main__":
kw = input(‘输入搜索关键词:‘)
url = ‘https://search.bilibili.com/all/‘
headers = {
‘user_agent‘:‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.146 Safari/537.36‘
}
data = {
‘keyword‘:kw
}
response = requests.get(url=url,params=data,headers=headers)
page_text = response.text
FileName = kw+‘.html‘
with open(FileName,‘w‘,encoding=‘utf-8‘) as fp:
fp.write(page_text)
print(FileName,‘成功!!‘)
输入搜索关键词:爬虫
爬虫.html 成功!!
Press any key to continue . . .
标签:strong bilibili app 程序包 odi python爬虫 执行 with open input
原文地址:https://www.cnblogs.com/ct-debug/p/14374859.html