爬虫学习
今天学习了反爬取:
代码
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()