码迷,mamicode.com
首页 > 编程语言 > 详细

用python提取xml里面的链接源码

时间:2019-10-15 13:38:53      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:map   链接   find   site   地图   sitemap   com   lib   odi   

  因群里朋友需要提取xml地图里面的链接,就写了这个程序。

  代码:

   

#coding=utf-8
import urllib
import urllib.request 
import re
url=‘http://zhimo.yuanzhumuban.cc/sitemaps.xml‘
html=urllib.request.urlopen(url).read()
html=html.decode(‘utf-8‘)
r=re.compile(r‘(http://zhimo.yuanzhumuban.cc.*?\.html)‘)
big=re.findall(r,html)
for i in big:
 print(i)
 op_xml_txt=open(‘xml.txt‘,‘a‘)
 op_xml_txt.write(‘%s\n‘%i)

  

   

用python提取xml里面的链接源码

标签:map   链接   find   site   地图   sitemap   com   lib   odi   

原文地址:https://www.cnblogs.com/68xi/p/11676960.html

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