手机
当前位置:查字典教程网 >脚本专栏 >python >python使用正则表达式提取网页URL的方法
python使用正则表达式提取网页URL的方法
摘要:本文实例讲述了python使用正则表达式提取网页URL的方法。分享给大家供大家参考。具体实现方法如下:importreimporturlli...

本文实例讲述了python使用正则表达式提取网页URL的方法。分享给大家供大家参考。具体实现方法如下:

import re import urllib url="http://www.jb51.net" s=urllib.urlopen(url).read() ss=s.replace(" ","") urls=re.findall(r"<a.*?href=.*",ss,re.I) for i in urls: print i else: print 'this is over'

PS:这里再为大家提供2款非常方便的正则表达式工具供大家参考使用:

JavaScript正则表达式在线测试工具:

http://tools.jb51.net/regex/javascript

正则表达式在线生成工具:

http://tools.jb51.net/regex/create_reg

希望本文所述对大家的Python程序设计有所帮助。

【python使用正则表达式提取网页URL的方法】相关文章:

python中stdout输出不缓存的设置方法

python使用正则表达式提取网页URL的方法

python使用正则搜索字符串或文件中的浮点数代码实例

python ip正则式

简单文件操作python 修改文件指定行的方法

python操作日期和时间的方法

Python转码问题的解决方法

python使用正则表达式检测密码强度源码分享

python生成器的使用方法

PYTHON正则表达式 re模块使用说明

精品推荐
分类导航