Python开发:正则表达式获得URL
2013-04-21 16:35
375 查看
用正则表达式获得a标签中的链接地址
import urllib2
from BeautifulSoup import BeautifulSoup
import re
fp = urllib2.urlopen('http://www.baidu.com')
soup = BeautifulSoup(fp)
p=re.compile(r'<a.*?href=["\'](.*?)["\']+')
for m in re.findall(p,str(soup)):
print m,'\n'
import urllib2
from BeautifulSoup import BeautifulSoup
import re
fp = urllib2.urlopen('http://www.baidu.com')
soup = BeautifulSoup(fp)
p=re.compile(r'<a.*?href=["\'](.*?)["\']+')
for m in re.findall(p,str(soup)):
print m,'\n'
相关文章推荐
- 使用python和正则表达式获取url,及总结
- Python 正则表达式验证URL
- 正则表达式分割URL,获得二级域名
- python+正则表达式获取ed2k url
- Python 正则表达式提取URL中的Query
- Python 正则表达式将URL转化为带链接的URL
- PYTHON 开发 正则表达式
- Python 正则表达式提取URL中的Host
- Python 正则表达式提取URL中的Path
- ios开发中使用正则表达式识别处理字符串中的URL
- iOS开发正则表达式,验证是否是邮箱,手机号,银行卡号,URL等等
- python使用正则表达式解析http url
- Python 正则表达式查找带有小括号的URL
- Python验证Url地址的正则表达式
- <Python高级全栈开发工程师-1>学习过程笔记【181-184】正则表达式 <特殊字符><函数>
- Python验证Url地址的正则表达式
- ios开发中使用正则表达式识别处理字符串中的URL
- python使用正则表达式提取网页URL的方法
- python3.4学习笔记(十二) python正则表达式的使用,使用pyspider匹配输出带.html结尾的URL