ptyhon实现sitemap生成示例

457次阅读  |  发布于5年以前

复制代码 代码如下:

* coding:utf-8 *

xiaohei.python.seo.call.me:)

win+python2.7.x

id = 1
f = open('clubpop%s.xml' % id
, 'w')

for i, line in enumerate(open('suk.csv')):
if i % 50000==0:
print i
f.write('<?xml version="1.0" encoding="UTF-8"?>\n\n')

    f.write('''     <url>  
            <loc>http://www.jb51.net/review/%s-1-1.html</loc>  
    </url>  

''' % line.rstrip())
if i % 50000==49999:
f.write('')
f.close()
id += 1
f = open('clubpop%s.xml' % id
, 'w')
f.write('')
f.close()

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8