找出所有链接的python脚本
发布时间:2020-12-17 17:10:06 所属栏目:Python 来源:网络整理
导读:今天PHP站长网 52php.cn把收集自互联网的代码分享给大家,仅供参考。 import requestsimport re# get urlurl = input('Enter a URL (include `http://`): ')# connect to the urlwebsite = requests.get(url)# read htmlh
以下代码由PHP站长网 52php.cn收集自互联网 现在PHP站长网小编把它分享给大家,仅供参考 import requests import re # get url url = input('Enter a URL (include `http://`): ') # connect to the url website = requests.get(url) # read html html = website.text # use re.findall to grab all the links links = re.findall('"((http|ftp)s?://.*?)"',html) # output links for link in links: print(link[0]) |