用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\n'%i)

  

   

posted @ 2019-10-15 12:26  圆柱模板  阅读(328)  评论(0编辑  收藏  举报