程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python crawler series of get things web page version details page sign signature algorithm

編輯:Python

Python Crawler series of the content of the web page version of the details page sign Signature algorithm

If you have any questions > Click here to contact us <

The code is for learning and communication only , Do not use for illegal purposes , Encryption key not provided , For reference only

Go straight to the code

import hashlib
import requests
import json
import random
import execjs
from sign import getSign,getSessionId,getShumeiId
tunnel = "
username = ""
password = ""
proxies = {

"http": "http://%(user)s:%(pwd)[email protected]%(proxy)s/" % {
"user": username, "pwd": password, "proxy": tunnel},
"https": "http://%(user)s:%(pwd)[email protected]%(proxy)s/" % {
"user": username, "pwd": password, "proxy": tunnel}
}
def getProductDetail(spuId):
try:
url = "https://app.dewu.com/api/v1/h5/index/fire/flow/product/detail"
data = {

"spuId": str(spuId),
"productSourceName": "",
"propertyValueId": "",
"sourceName": "shareDetail"
}
data['sign'] = getSign(data)
headers = {

"AppId": "h5",
"appVersion": "4.4.0",
"Content-Type": "application/json",
"Host": "app.dewu.com",
"Origin": "https://m.dewu.com",
"platform": "h5",
"Referer": "https://m.dewu.com/",
"sec-ch-ua": '"Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"',
"sec-ch-ua-mobile": "?0",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"sessionid": getSessionId(),
"shumeiId": getShumeiId(),
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Mobile Safari/537.36",
}
resp = requests.post(url, data=json.dumps(data), proxies=proxies, headers=headers, timeout=8)
print("request start--------------------------------")
print("proxies :" + str(proxies))
print("status_code :" + str(resp.status_code))
print("data :" + str(resp.json()))
print("request end--------------------------------")
except Exception as e:
pass
def queryBuyNowInfo(spuId):
url = "https://app.dewu.com/api/v1/h5/inventory/price/h5/queryBuyNowInfo"
data = {
"spuId": str(spuId)}
data['sign'] = getSign(data)
headers = {

"AppId": "h5",
"appVersion": "4.4.0",
"Content-Type": "application/json",
"Host": "app.dewu.com",
"Origin": "https://m.dewu.com",
"platform": "h5",
"Referer": "https://m.dewu.com/",
"sec-ch-ua": '"Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"',
"sec-ch-ua-mobile": "?0",
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-site",
"sessionid": getSessionId(),
"shumeiId": getShumeiId(),
"User-Agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.81 Mobile Safari/537.36",
}
resp = requests.post(url, data=json.dumps(data), proxies=proxies, headers=headers, timeout=8)
print("request start--------------------------------")
print("proxies :" + str(proxies))
print("status_code :" + str(resp.status_code))
print("data :" + str(resp.json()))
print("request end--------------------------------")
def run():
spuId = "28592"
queryBuyNowInfo(spuId)
getProductDetail(spuId)
if __name__ == '__main__':
run()
  • Run a screenshot


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved