爬虫爬虫405 Not Allowed Request Payload

只需要换个参数就行了,post_data, headers, url

*现在比较忙抽空再写个解释吧

参数为json
data=json.dumps(self.post_data)

import requests
import json

class InfoTec(object):
def __init__(self):

    self.headers = {
        'authority': 'api.**************.com',
        'method': 'POST',
        'path': '/api********************rticles',
        'scheme': 'https',
        'accept': 'application/json, text/plain, */*',
        'accept-encoding': 'zh-CN,zh;q=0.9',
        'content-length': '179',
        'content-type': 'application/json',
        'origin': 'htt**************g.com',
        'referer': '//ww************',
        'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3**8.77 Safari/537.36'
    }


    self.post_data = {

        "data":{
            "AccountId": 'null',
              "TagId": 'null',
              "ChannelId": 'null',
              "ArticleCategoryId": 'null',
              "CompanyId": 'null',
              "TopicId": 'null',
              "IndustryId": "lm***d",
              "Current": 9,
              "Psize": 9,},
         "token":'null'
    }
    
def li_index_page(self):

    url = 'https://api.*******icles'
    response = requests.post(url, data=json.dumps(self.post_data), headers=self.headers)
    return response.text

def run(self):

    res = self.li_index_page()
    print(res)

    pass

if __name__ == '__main__':
    infotec = InfoTec()
    infotec.run()

405 介绍

https://www.checkupdown.com/status/E405_zh.html

你可能感兴趣的:(p爬虫)