Python请求:方法不允许错误

Python请求:方法不允许错误,python,python-requests,Python,Python Requests,我试图通过使用requests.get()访问URL,但它给出了405。通过浏览器访问时没有此类问题。只是猜测,可能是因为您试图直接访问页面 你能尝试添加一个推荐url吗 其中my_referer是网站主页的url get(url,headers={'referer':my_referer})我已经添加了所需的正确的头,请尝试以下操作 import requests headers = { "Host": "www.propertyshark.com",

我试图通过使用
requests.get()
访问URL,但它给出了405。通过浏览器访问时没有此类问题。

只是猜测,可能是因为您试图直接访问页面

你能尝试添加一个推荐url吗 其中my_referer是网站主页的url


get(url,headers={'referer':my_referer})

我已经添加了所需的正确的头,请尝试以下操作

import requests

headers = {
                "Host": "www.propertyshark.com",
                "Connection": "keep-alive",
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36",
                "Upgrade-Insecure-Requests": "1",
                "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
                "Accept-Encoding": "gzip, deflate, br",
                "Accept-Language": "en-US,en;q=0.9",
}

url = "https://www.propertyshark.com/mason/Property/53047525/1302-Richland-Ave-Santa-Ana-CA-92703/"

req = requests.get(url, headers=headers)
print(req.status_code)

检查浏览器的标题数据,并设置发送标题的请求same@Volatil3为什么是随机的?否则会显示什么?然后会显示405。