【发布时间】:2019-01-08 21:11:36
【问题描述】:
我只是使用下面的代码解析来自 url 的链接。找到了链接,但是我的计数器不起作用。请对如何修复我的柜台有任何想法? 谢谢
def parse_all_links(html):
links = re.findall(r"""a href=(['"].*['"])""", html)#find links starting with href
print("found the following links addresses: ".format(len(html)))#print a message before the output
if len(links) ==0:
print("Sorry, no links found")
else:
count = 1#this count how many links are displayed
for e in links:
print(e)
count += 1
print('--------------')
【问题讨论】:
-
您能否澄清一下“我的计数器不起作用”的意思?
-
您好,我运行代码时会显示实际链接,但我看不到链接总数
-
我的回答解决了您的问题吗?
-
是的,非常感谢 mrangry777 :)
标签: python parsing url hyperlink counter