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

  因群里朋友需要提取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
'%i)

  

   

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