我使用的是 python 爬虫。 HTTP 405 Error 的爆发原因是什么?

I was using the python crawler. why cause of outbreak the HTTP 405 Error?

我英语不好。所以请大家好好理解我笨拙的英语。

我尝试使用 HTTP POST 来抓取 Google

但是出现了一些问题。

问题是输出页面出现 HTTP 405 错误

这是python 3.5.1 来源

import requests
from bs4 import BeautifulSoup

def image_upload():
    filePath = 'C:/test.jpg'
    searchUrl = 'http://www.google.com/searchbyimage/upload'
    multipart = {'encoded_image': (filePath, open(filePath, 'rb')), 'image_content': ''}
    response = requests.post(searchUrl, files=multipart, allow_redirects=False)
    plain_text = response.text
    soup = BeautifulSoup(plain_text,"html.parser")
    for link in soup.find_all('a'):
        return  link.get('href')

def Crawling(target_link):
    response = requests.post(target_link)
    html_content = response.text.encode(response.encoding)
    soup = BeautifulSoup(html_content, "html.parser")
    edutData = soup.find_all('a', {'class':'bili uh_r rg_el uvg-i'})
    print(soup)

iamge_link = image_upload()
print(iamge_link)
Crawling(iamge_link)

为什么在输出页面中出现 HTTP 405 错误问题?

当您使用的请求方法不受支持时,会返回 HTTP 响应 405。在您的情况下,您正在访问的端点可能不支持 post 方法。

供参考,Http Response 405