码迷,mamicode.com
首页 > 其他好文 > 详细

用正则表达式完成xpath的功能(强大的正则表达式)

时间:2017-11-30 00:55:15      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:money   class   完成   int   print   mon   bsp   text   mpi   

1 url = http://money.163.com/special/pinglun
2 response = requests.get(url)
3 # regex = re.compile(‘‘‘<li><span class="article"><a href="([^"]+?)">([^<]?)</a></span><span class="atimef12px">\(([^\)]+?)\)</span></li>‘‘‘)
4 res = re.findall(r<a href="([^"]+?)" title="([^"]+?)">,response.text)
5 for l in res:
6     print(l[0])
7     print(l[1])

 

用正则表达式完成xpath的功能(强大的正则表达式)

标签:money   class   完成   int   print   mon   bsp   text   mpi   

原文地址:http://www.cnblogs.com/liyugeng/p/7923400.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!