用python 获取网站内的所有页面内的所有 连接(包括分页在内)
1条回答 默认 最新
- threenewbee 2023-04-13 10:20关注
import requests from bs4 import BeautifulSoup def gl(url): l = [] r = requests.get(url) s = BeautifulSoup(r.content, 'html.parser') for a in s.find_all('a'): h = a.get('href') if h and (h.startswith('http') or h.startswith('https')): l.append(h) return l def gal(bu): al = [] al.append(bu) pl = gl(bu) al.extend(pl) for l in pl: fl = gl(l) al.extend(fl) return al all_links = gal('https://www.你的网站.com') print(all_links)
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 pyqt5tools安装失败
- ¥15 mmdetection
- ¥15 nginx代理报502的错误
- ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
- ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
- ¥100 描述一下元器件的基本功能,pcba板的基本原理
- ¥15 STM32无法向设备写入固件
- ¥15 使用ESP8266连接阿里云出现问题
- ¥15 BP神经网络控制倒立摆
- ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果