萌新求问,requests.get()
求问各路大佬,为什么我用ie浏览器打开网址 http://www.xiachufang.com/用搜狗浏览器打开,就是404,而且我用
import requests
from bs4 import BeautifulSoup
res_foods = requests.get('http://www.xiachufang.com/explore/')
print(res_foods.status_code)
返回的是404
求问这个问题怎么解决 实测没有问题
请问您用那段代码就可以返回的是200吗0.0,那是我Python安装有问题吗。。。 网站检测User-Agent头了,自定义一个就行
import requests
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
}
res_foods = requests.get('http://www.xiachufang.com/explore/',headers=headers)
print(res_foods.status_code)
页:
[1]