【发布时间】:2022-01-22 19:01:31
【问题描述】:
我想只获取 URL 而不重定向链接。 我的代码是:
html = '<a class="css-10y60kr" href="/biz_redir?url=https%3A%2F%2Faceplumbingandrooter.com&cachebuster=1642876680&website_link_type=website&src_bizid=hqjCHBGnEj4nECnLJBvjQw&s=2caa69aa7350cca9ad00f1fd1d5a6346f341dd43e1ede874aa2eaa94d6a3458f" rel="noopener nofollow" role="link" target="_blank">https://aceplumbingandrooter.c…</a>'
soup=BeautifulSoup(html,'lxml')
在标签['href'] 内容中:
href="/biz_redir?url=https%3A%2F%2Faceplumbingandrooter.com&cachebuster=1642876680&website_link_type=website&src_bizid=hqjCHBGnEj4nECnLJBvjQw&s=2caa69aa7350cca9ad00f1fd1d5a6346f341dd43e1ede874aa2eaa94d6a3458f"
我只想要链接网址:aceplumbingandrooter.com
【问题讨论】:
标签: python web-scraping beautifulsoup