用Python从网站上删除搜索栏

2024-09-29 17:22:48 发布

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

我在:https://www.partsfinder.com/catalog/preview?q=0119000230this网站的搜索栏上有一个零件号列表。你知道吗

我想从结果中收集价格。你知道吗

以下是我总结出来的东西,但我不知道从这里走到哪里:

import requests
from bs4 import BeautifulSoup

r = requests.get('https://www.partsfinder.com/catalog/preview?q=0119000230')
soup = BeautifulSoup(r.text, 'html.parser')
resultsRow = soup.find_all('a', {'class': 'search_result_row'})
results = []

感谢您的帮助,谢谢!你知道吗


Tags: fromhttpsimportcom列表网站www价格
1条回答
网友
1楼 · 发布于 2024-09-29 17:22:48

内容通过xhr POST请求动态加载。刷新页面时,您可以在浏览器的开发工具中看到这一点。您可以将请求最小化为以下内容:

import requests

data = {"partOptionFilter":{"PartNumber":"0119000230","AlternativeOemId":"17155"}}
r = requests.post('https://www.partsfinder.com/Catalog/Service/GetPartOptions',json=data).json()
print(r['Data']['PartOptions'][0]['YourPrice'])       

相关问题 更多 >

    热门问题