python 提取url中域名
2013-06-12 21:27
267 查看
import re re.compile(r'^(http(s)?://)?([\w-]+\.)+[\w-]+/?')
正则式()表示
(exp) 匹配exp,并捕获文本到自动命名的组里
所以
当url='http://www.360buy.com/product/755411.html'
print p.search(url).group(0) -> http://www.360buy.com/ print p.search(url).group(1) -> http:// print p.search(url).group(2) -> None
print p.search(url).group(3) -> 360buy.
print p.findall(url) -> [('http://', '', '360buy.')]
re的匹配结果为寻找符合()内规则的匹配集合
相关文章推荐
- Python实现从url中提取域名的几种方法
- 黄聪:用python知道URL地址提取链接中的域名与端口
- Python实现从url中提取域名的几种方法
- python提取URL地址链接中的域名与端口
- 用python提取url链接中的域名与端口
- 用python提取url链接中的域名与端口
- 黄聪:用python知道URL地址提取链接中的域名与端口
- Python实现从url中提取域名的几种方法
- 用Python提取url链接中的域名与端口
- Python 2.7_爬取CSDN单页面利用正则提取博客文章及url_20170114
- [Python]从url中解析域名的几种方法
- Python 正则表达式提取URL中Port
- python提取页面内url列表的方法
- 【Python编程】网页URL提取实例
- PHP 从 URL 中提取域名 函数
- Python实现从URL地址提取文件名的方法
- python解析URL中的域名
- Python 2.7_爬取CSDN单页面博客文章及url(二)_xpath提取_20170118
- java如何提取url里的域名
- Python 正则表达式提取URL中的USER