Post请求返回404

2024-10-01 11:30:12 发布

您现在位置:Python中文网/ 问答频道 /正文

最后,我想“刮”下面的网页时,做一个高级搜索在过去两天。 https://launchstudio.bluetooth.com/Listings/Search

结果似乎是由调用API的javascript生成的

bt.apiUrl = 'https://platformapi.bluetooth.com/';
$.ajax({
    method: 'post',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    url:  bt.apiUrl +'api/platform/Listings/Search',
    data: JSON.stringify(this.searchCriteria),
    success: function (data) {
        if (data.length) {
            var listings = data
            console.log('listing count: ' + listings.length);
            this.listings = listings;
        }

    }.bind(this)

找到以下API文档: https://platformapi.bluetooth.com/Help/Api/POST-api-Platform-Listings-Search

但是,我的简单脚本返回404

^{pr2}$

有人知道为什么吗?使用python3.5 btw


Tags: httpscomapijsonsearchdatathislength
1条回答
网友
1楼 · 发布于 2024-10-01 11:30:12
import requests
import json

payload = {
    "searchString":"bluetooth",
    "searchQualificationsAndDesigns":True,
    "searchDeclarationOnly":True,
    "searchEndProductList":False,
    "searchPRDProductList":True,
    "searchMyCompany":False,
    "productTypeId":0,
    "specName":0,
    "bqaApprovalStatusId":-1,
    "bqaLockStatusId":-1,
    "listingDateEarliest":"",
    "listingDateLatest":"",
    "userId":0,
    "memberId":None,
    "layers":[],
    "maxResults":5000
    }

url = 'https://platformapi.bluetooth.com/api/Platform/Listings/Search'
headers = {'Content-type': 'application/json; charset=utf-8', 'Accept': 'text/json'}
r = requests.post(url, data=json.dumps(payload), headers=headers)
print (r.status_code)
#print r.json()

结果:

^{pr2}$

相关问题 更多 >