导入相关库

import requests import re

指定目标网站

url = 'https://www.baidu.com/'

发送请求

response = requests.get(url)

使用正则表达式匹配所有链接

links = re.findall(r'href="(.*?)"', response.text)

打印所有链接

for link in links: print(link)

完成- -个完整的python程序开放类型爬虫基本要求 3、自行编写不用BeautifulSoup不得在网上拷贝 4必须百度首页获取一个指定网站 5用新手能看懂的代码

原文地址: https://www.cveoy.top/t/topic/gEiJ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录