发送get请求
1、不带参数的请求
import requests
url = https://movie.douban.com/j/search_subjects
x = requests.get(url)
print (x.statue_code)
返回200 表示正常,如果非200,说明网站设置了反爬虫,需要带上参数
2、带参数的请求
import requests
url = https://movie.douban.com/j/search_subjects
query_head ={
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36"
}
x = requests.get(url, headers = query_head)
print (x.statue_code)
返回200