ptyhon实现sitemap生成示例

yipeiwu_com6年前Python基础

复制代码 代码如下:

# _*_ 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<urlset>\n')

        f.write('''     <url>
                <loc>//www.jb51.net/review/%s-1-1.html</loc>
        </url>
''' % line.rstrip())
        if i % 50000==49999:
                f.write('</urlset>')
                f.close()
                id_ += 1
                f = open('clubpop%s.xml' % id_, 'w')
f.write('</urlset>')
f.close()

相关文章

用pyqt5 给按钮设置图标和css样式的方法

如下所示: 设置图标 self.pushButton.setIcon(QIcon("sure.png")) 设置css样式 self.pushButton.setStyleSh...

python3编写ThinkPHP命令执行Getshell的方法

python3编写ThinkPHP命令执行Getshell的方法

加了三个验证漏洞以及四个getshell方法 # /usr/bin/env python3 # -*- coding: utf-8 -*- # @Author: Morker #...

numpy 返回函数的上三角矩阵实例

numpy 返回函数的上三角矩阵 np.triu() matrix2=np.triu(matrix1) numpy.triu(m, k=0)[source] Upper tri...

python读取csv文件并把文件放入一个list中的实例讲解

如下所示: #coding=utf8 ''' 读取CSV文件,把csv文件放在一份list中。 ''' import csv class readCSV(object): def...

调用其他python脚本文件里面的类和方法过程解析

这篇文章主要介绍了调用其他python脚本文件里面的类和方法过程解析,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 问题描述: 自己编...