爬虫学习

今天学习了反爬取:

代码

import requests
a = input("你最喜欢的明星是")
url = f'https://www.sogou.com/web?query={a}'
headers = {
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3947.100 Safari/537.36"
}
resp = requests.get(url,headers=headers)
print(resp)
print(resp.text)
resp.close()

posted @ 2021-06-05 16:07  潘福龙  阅读(32)  评论(0编辑  收藏  举报