代码如下:
import requests
import re
url = "https://www.haagendazs.com.cn/products/cake"
headers = {
"user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36 Edg/91.0.864.54"
}
dat = {
"actionsHistory": [{"name":"Query","time":"\"2021-06-21T08:05:16.209Z\""},{"name":"Query","time":"\"2021-06-21T08:00:20.250Z\""},{"name":"Query","time":"\"2021-06-21T07:59:15.402Z\""},{"name":"Query","time":"\"2021-06-21T01:31:28.699Z\""},{"name":"Query","time":"\"2021-06-21T01:28:51.734Z\""},{"name":"Query","time":"\"2021-06-18T04:35:08.934Z\""},{"name":"Query","time":"\"2021-06-18T01:19:52.768Z\""},{"name":"Query","time":"\"2021-06-17T07:11:13.747Z\""},{"name":"Query","time":"\"2021-06-17T06:34:19.443Z\""},{"name":"Query","time":"\"2021-06-16T09:48:59.447Z\""},{"name":"Query","time":"\"2021-06-16T09:40:35.778Z\""}],
"referrer":"",
"visitorId": "8fa6a9ab-a561-42e1-ad19-f7795d9826bb",
"isGuestUser": "false",
"aq": (("@z95xpath"=="C378A96BB2E74B5FBDBCFFD40F519A15" ("@gmicategory4"=="所有蛋糕" "@z95xtemplate"=="2B0F0724046E49E888522B9DA9E585F7"))) ("@syssource"=="Coveo_web_index - brand-platform-prod"),
"cq": ("@z95xlanguage"=="zh-CN") ("@z95xlatestversion"==1),
"searchHub": "HaagenDazs-CN",
"tab":"cake",
"locale": "zh-CN",
"pipeline": "HaagenDazs",
"maximumAge": "900000",
"firstResult": "0",
"numberOfResults": "10",
"excerptLength": "200",
"enableDidYouMean": "false",
"sortCriteria": "relevancy",
"queryFunctions": [],
"rankingFunctions": [],
"groupBy": [{"field":"@gmicategory3","maximumNumberOfValues":"6","sortCriteria":"occurrences","injectionDepth":"1000","completeFacetWithStandardValues":"true","allowedValues":[]},{"field":"@gmicategory4","maximumNumberOfValues":"6","sortCriteria":"occurrences","injectionDepth":"1000","completeFacetWithStandardValues":"true","allowedValues":[]},{"field":"@gmicategory5","maximumNumberOfValues":"6","sortCriteria":"occurrences","injectionDepth":"1000","completeFacetWithStandardValues":"true","allowedValues":[]}],
"facetOptions": {},
"categoryFacets": [],
"retrieveFirstSentences": "true",
"timezone": "Asia"/"Shanghai",
"enableQuerySyntax": "false",
"enableDuplicateFiltering": "false",
"enableCollaborativeRating": "false",
"debug": "false",
"allowQueriesWithoutKeywords": "true"
}
#发送post请求,发送的数据必须放在字典中,通过data参数进行传递
resp = requests.get(url,headers=headers,data=dat)
#print(resp.text)
print(resp.text) #将服务器返回的内容直接处理成json => dict
#a = resp.json()
#print(a)
resp.close() #关掉resp