此页https://www.kijiji.ca/v-1-bedroom-apartments-condos/ville-de-montreal/1-chambre-chauff-eau-chaude-incl-vsl-514-856-0038/1334431659包含此span类:
<span class="currentPrice-3131760660"><span content="800.00">800,00 $</span>
我试图自动提取价格(在这个例子中是800美元)。但是,随着时间的推移,“currentPrice-”后面的数字会发生变化,我的Python脚本将停止工作。我正在使用这个漂亮的汤功能:
^{pr2}$
如何使用find_all来提取类名的部分匹配,例如包含字符串“currentPrice-”的所有类?在
Tags:
根据docs你有几个选择:
使用正则表达式:
使用函数:
你可以试试CSS选择器
soup.select('span[class*="currentPrice-"]')
相关问题 更多 >
编程相关推荐