自己爬不动了,寻求支持
本帖最后由 wp231957 于 2023-4-28 18:52 编辑https://www.philips.com.cn/c-w/search.html#q=%E7%A9%BA%E6%B0%94%E5%87%80%E5%8C%96%E5%99%A8&sort=relevancy
这里面有1314条记录 我想获取他们的二级链接
这里面有个payload 面板 完全看不懂啊
这里面q=空气净化器 import requests
url = 'https://koninklijkephilipsnvproduction2k8xfrmr.org.coveo.com/rest/search/v2'
headers = {
'Authorization': 'Bearer xx0d641857-e140-4e94-af32-ea8fe1063ce8'
}
num = requests.post(url, data={'q': '空气净化器'}, headers=headers).json()['totalCount']
resp = requests.post(url, data={'q': '空气净化器', 'numberOfResults': num}, headers=headers)
results = resp.json()['results']
for i in results:
print(i['uri'])
print(f'一共有{num}个结果')
本帖最后由 isdkz 于 2023-4-28 20:26 编辑
我觉得授人以鱼不如授人以渔,所以在这里给出过程,给你一些 chatgpt 工程师的参考{:10_256:} :
一、先在浏览器的开发者工具中搜索空气净化器的数据来自于哪个请求
二、然后将该http请求包的内容丢到 chatgpt 询问
三、然后自己调测一下,就有了以下的代码:
import requests
url = 'https://koninklijkephilipsnvproduction2k8xfrmr.org.coveo.com/rest/search/v2'
headers = {
'Authorization': 'Bearer xx0d641857-e140-4e94-af32-ea8fe1063ce8'
}
num = requests.post(url, data={'q': '空气净化器'}, headers=headers).json()['totalCount']
resp = requests.post(url, data={'q': '空气净化器', 'numberOfResults': num}, headers=headers)
results = resp.json()['results']
for i in results:
print(i['uri'])
print(f'一共有{num}个结果')
本帖最后由 wp231957 于 2023-4-28 20:49 编辑
isdkz 发表于 2023-4-28 20:00
略改进:
就是把前面的产品 勾挑
https://www.philips.com.cn/c-w/search.html#q=空气净化器&sort=relevancy&f:@commoncontenttypedict=[产品]
但是代码运行错误:
import requests
url = 'https://koninklijkephilipsnvproduction2k8xfrmr.org.coveo.com/rest/search/v2'
headers = {
'Authorization': 'Bearer xx0d641857-e140-4e94-af32-ea8fe1063ce8'
}
num = requests.post(url, data={'q': '空气净化器'}, headers=headers).json()['totalCount']
data={
'facets':
{
"facetId":"@commoncontenttypedict",
"field":"commoncontenttypedict",
"type":"specific",
"injectionDepth":1000,
"filterFacetCount":'true',
"currentValues":[{"value":"产品","state":"selected"}],
"numberOfValues":8,
"freezeCurrentValues":'false',
"preventAutoSelect":'false',
"isFieldExpanded":'false'
},
"q":"空气净化器",
'numberOfResults': num
}
resp = requests.post(url, data=data, headers=headers)
print(resp.json())
results = resp.json()['results']
for i in results:
print(i['uri'])
print(f'一共有{num}个结果')
isdkz 发表于 2023-4-28 20:21
我觉得授人以鱼不如授人以渔,所以在这里给出过程,给你一些 chatgpt 工程师的参考 :
一、先 ...
谢了,我没有chatgpt wp231957 发表于 2023-4-28 20:26
略改进:
就是把前面的产品 勾挑
https://www.philips.com.cn/c-w/search.html#q=空气净化器&sort=re ...
import requests
url = 'https://koninklijkephilipsnvproduction2k8xfrmr.org.coveo.com/rest/search/v2'
headers = {
'Authorization': 'Bearer xx0d641857-e140-4e94-af32-ea8fe1063ce8'
}
data1 = {'q': '空气净化器', 'facets': '[{"field":"commoncontenttypedict", "currentValues":[{"value":"产品","state":"selected"}]}]'}
num = requests.post(url, data=data1, headers=headers).json()['totalCount']
data2={
'facets': '[{"field":"commoncontenttypedict", "currentValues":[{"value":"产品","state":"selected"}]}]',
"q":"空气净化器",
'numberOfResults': num
}
resp = requests.post(url, data=data2, headers=headers)
print(resp.text)
results = resp.json()['results']
for i in results:
print(i['uri'])
print(f'一共有{num}个结果')
wp231957 发表于 2023-4-28 20:28
谢了,我没有chatgpt
ai.wuguokai.cn
https://chat2.aichatos.top/
https://chat.jinshutuan.com
等等
页:
[1]