我正在学习使用Python进行web报废。我正在尝试从热门金融网站的网站地图中提取所有链接。Python正则表达式不会返回任何匹配结果
bsObj = BeautifulSoup(html, "html.parser")
for link in bsObj.findAll("a",
href=re.compile("^(/india/stockmarket/pricechartquote/)*$")):
if 'href' in link.attrs:
print(link.attrs['href'])
print('found nothing')
此代码没有找到任何内容。尽管现场有很多与上述匹配的链接。 示例:/印度/股市/ pricechartquote/A
是'HREF = ...'线正确缩进? – depperm