python使用BeautifulSoup分页网页中超链接的方法
作者:令狐不聪 时间:2023-11-21 07:24:49
本文实例讲述了python使用BeautifulSoup分页网页中超链接的方法。分享给大家供大家参考。具体如下:
python通过BeautifulSoup分页网页中的超级链接,这段python代码输出www.jb51.net主页上所有包含了jb51的url链接
from BeautifulSoup import BeautifulSoup
import urllib2
import re
url = urllib2.urlopen("https://www.jb51.net")
content = url.read()
soup = BeautifulSoup(content)
for a in soup.findAll('a',href=True):
if re.findall('sharejs', a['href']):
print "Found the URL:", a['href']
希望本文所述对大家的Python程序设计有所帮助。
标签:python,BeautifulSoup
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python实战之利用Geopandas算出每个省面积
2022-05-11 07:46:39
![](https://img.aspxhome.com/file/2023/3/135253_0s.jpg)
golang协程关闭踩坑实战记录
2024-02-13 00:02:57
![](https://img.aspxhome.com/file/2023/3/113083_0s.png)
numpy数组切片的使用
2023-10-30 04:36:24
![](https://img.aspxhome.com/file/2023/9/67249_0s.png)
MSSQL存储过程分页,ASP存储过程分页
2009-09-11 12:50:00
SQL2005查看死锁存储过程sp_who_lock
2024-01-12 20:34:13
Python列表(list)、字典(dict)、字符串(string)基本操作小结
2023-03-02 01:33:01
基于Python编写一个ISBN查询工具
2022-02-22 09:43:21
![](https://img.aspxhome.com/file/2023/3/83773_0s.png)
详解vue服务端渲染(SSR)初探
2024-05-11 09:16:13
![](https://img.aspxhome.com/file/2023/9/126419_0s.png)
基于Python实现骰子小游戏
2023-07-11 22:39:58
![](https://img.aspxhome.com/file/2023/3/128443_0s.jpg)
python docx 中文字体设置的操作方法
2021-01-12 22:33:44
Python面向对象之静态属性、类方法与静态方法分析
2021-03-28 15:14:22
Python编写淘宝秒杀脚本
2021-01-31 23:23:42
![](https://img.aspxhome.com/file/2023/8/79418_0s.jpg)
Linux 7下脚本安装配置oracle 11g r2教程
2024-01-13 13:35:56
response.setHeader()方法设置http文件头的值
2010-03-11 22:43:00
matplotlib绘制多个子图(subplot)的方法
2023-01-17 08:27:45
vue2 利用echarts 单独绘制省份的步骤
2024-04-09 10:45:42
![](https://img.aspxhome.com/file/2023/3/139853_0s.png)
PHP简单检测网址是否能够正常打开的方法
2023-11-17 22:22:56
![](https://img.aspxhome.com/file/2023/7/104187_0s.jpg)
人工智能学习Pytorch梯度下降优化示例详解
2023-02-11 16:28:02
![](https://img.aspxhome.com/file/2023/6/72816_0s.png)
Mac下使用HomeBrew安装python3
2021-02-28 08:17:57
![](https://img.aspxhome.com/file/2023/3/86413_0s.png)
JS删除数组里的某个元素方法
2023-07-14 22:45:47