[英]Using BeautifulSoup to search for a tag with certain attributes, but NOT fixed attribute values
我有以下HTML,我正嘗試通過beautifulsoup搜索:
<a href="/user_details?userid=**********">
問題是我想提取所有具有上述格式的鏈接,但是用戶ID可以更改。 我將如何去做?
謝謝!
會像
for link in soup.find_all('a'):
link_href = link.get('href')
if 'user_details' in link_href:
# found match
print link_href
絕招?
我們列出所有(鏈接)URL,在每個鏈接中搜索字符串“ user_details”(如果找到)-使用該鏈接。 如果user_details與其他內容匹配,則可以將其更改為其他內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.