爬豆瓣
import requests
head={"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.139 Safari/537.36"}#修改請求頭,偽裝成瀏覽器
#response =requests.get("http://books.toscrape.com/",headers=head) #這是個練習爬蟲的網站
response =requests.get("https://movie.douban.com/top250",headers=head)
if response.ok:
print(response.text)
else:
print("請求失敗")
print(response.status_code)