2017-11-19 2 views
0

Am Ende möchte ich die folgende Webseite "scrape", wenn Sie eine erweiterte Suche für die letzten zwei Tage. https://launchstudio.bluetooth.com/Listings/SearchPost Anfrage zurück 404

Ergebnisse scheint durch eine Javascript erzeugt werden, dass eine API

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) 

fanden die folgende API-Dokumentation ruft: https://platformapi.bluetooth.com/Help/Api/POST-api-Platform-Listings-Search

jedoch mein einfaches Skript gibt 404

import requests 
import json 

payload ={ 
    'UserId': '', 
    'MemberId': '', 
    'SearchString': '', 
    'SearchQualificationsAndDesigns': 1, 
    'SearchDeclarationOnly': 1, 
    'SearchEndProductList': 1, 
    'SearchPRDProductList': 1, 
    'SearchMyCompany': 1, 
    'BQAApprovalStatusId': 9, 
    'BQALockStatusId': 10, 
    'ProductTypeId': 1, 
    'SpecName': 1, 
    'ListingDateEarliest': "2017-11-17T09:43:09.2031162-06:00", 
    'ListingDateLatest': "2017-11-18T09:43:09.2031162-06:00", 
    'Layers': [], 
    'MaxResults': 11, 
    'IncludeTestData': 1 
} 

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

Jeder kann sehen warum? Verwenden von Python 3.5 BTW.

Antwort

1
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() 

Ergebnis:

200