python使用正则表达式提取网页URL的方法
作者:八大山人 时间:2023-10-09 16:27:18
本文实例讲述了python使用正则表达式提取网页URL的方法。分享给大家供大家参考。具体实现方法如下:
import re
import urllib
url="https://www.aspxhome.com"
s=urllib.urlopen(url).read()
ss=s.replace(" ","")
urls=re.findall(r"<a.*?href=.*?<\/a>",ss,re.I)
for i in urls:
print i
else:
print 'this is over'
希望本文所述对大家的Python程序设计有所帮助。
标签:python,正则表达式,URL
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
利用PyQt5模拟实现网页鼠标移动特效
2022-11-17 10:46:01
![](https://img.aspxhome.com/file/2023/9/92009_0s.png)
Node.js中console.log()输出彩色字体的方法示例
2024-05-02 17:37:54
![](https://img.aspxhome.com/file/2023/5/129485_0s.png)
解决 myJSFrame 框架中 Ajax 方法一处明显的内存泄露
2008-03-09 19:14:00
SQL Server数据库对于应用程序的关系
2010-09-08 09:42:00
SQL Server误区30日谈 第16天 数据的损坏和修复
2024-01-24 04:13:32
MySQL查询条件中in会用到索引吗
2024-01-15 06:46:43
![](https://img.aspxhome.com/file/2023/6/104426_0s.png)
详解SQL Server的聚焦过滤索引
2024-01-22 06:15:23
![](https://img.aspxhome.com/file/2023/7/96217_0s.png)
解决django中form表单设置action后无法回到原页面的问题
2023-06-27 00:27:54
window.location.hash属性介绍
2008-03-21 12:39:00
Python time.time()方法
2022-11-27 16:55:47
![](https://img.aspxhome.com/file/2023/6/127276_0s.png)
python自动化测试selenium执行js脚本实现示例
2023-10-23 06:41:58
Python多线程爬虫实战_爬取糗事百科段子的实例
2021-02-15 16:58:21
微信小程序audio组件在ios端无法播放的解决办法
2024-04-18 09:47:26
![](https://img.aspxhome.com/file/2023/3/136213_0s.png)
MSSQL基本语法及实例操作语句
2024-01-28 06:45:16
numpy自动生成数组详解
2023-09-02 22:53:47
js兼容的placeholder属性详解
2024-04-25 13:10:15
![](https://img.aspxhome.com/file/2023/3/135553_0s.jpg)
Mysql入门系列:MySQL数据目录的位置
2008-11-24 12:59:00
![](https://img.aspxhome.com/file/UploadPic/200811/20081129183226513.jpg)
java使用dbcp2数据库连接池
2024-01-29 05:33:42
![](https://img.aspxhome.com/file/2023/8/97798_0s.jpg)
简化翻页提升可用性
2009-03-28 11:52:00
![](https://img.aspxhome.com/file/UploadPic/20093/28/wp_pagenavi_1_en-28s.png)
django inspectdb 操作已有数据库数据的使用步骤
2024-01-24 00:16:50
![](https://img.aspxhome.com/file/2023/5/110015_0s.png)