我希望能够刮出链接列表。由于html的结构方式,我无法直接使用BeautifulSoup。从Python中的href标记中删除不需要的html
start_list = soup.find_all(href=re.compile('id='))
print(start_list)
[<a href="/movies/?id=actofvalor.htm"><b>Act of Valor</b></a>,
<a href="/movies/?id=actionjackson.htm"><b>Action Jackson</b></a>]
我正在寻找只拉href信息。我正在考虑某种过滤器,我可以将所有粗体代码放入列表中,然后将其从包含上述信息的另一个列表中过滤出来。
start_list = soup.find_all('a', href=re.compile('id='))
start_list_soup = BeautifulSoup(str(start_list), 'html.parser')
things_to_remove = start_list_soup.find_all('b')
的想法是能够遍历things_to_remove和START_LIST删除其内容全部出现
发布您想要的输出。 –