在网站上,我有此源代码
<div class="estimated-delivery">
<input id="currentCity" type="hidden" value="City">
<input id="currentCityISO" type="hidden" value="CY">
<input id="idUnit" type="hidden" value="3910200523">
<input id="availableOffers" type="hidden" value="4">
而且我用python写的
lastvalue = page_soup.find("div", {"class": "estimated-delivery"})
lastvalue.input["value"]
结果回来了
'City'
我不需要网站源代码第二行中的第一个值,我需要网站源代码中第五行的值是
'4'
谢谢
last_value = soup.find("input", {"id": "availableOffers"})
last_value = last_value["value"]
否则,请尝试:
last_value = soup.find_all("div", {"class": "estimated-delivery"}) last_value = last_value[3].input["value"]