易截截图软件、单文件、免安装、纯绿色、仅160KB

自动下载并保存博客 Python脚本

谢了一个自动下载指定人的博客的脚本
这个脚本是用来下载csdn博客的
同样的方法可以下载一般其他网站的博客,如sina
有时页面访问会被拒绝,重新运行即可
这种程序是在分析了指定网站,我在这儿是csdn,之后编写出的
会牵涉到网页的编码问题,有时程序运行会因此终止
我自己的博客已经下载忘了
只是下载网页
使用网页分析后可以整理出文章,那样更实用
#
#blogdownloader_csdn.py
# @Author:onezeros@yahoo.cn ||Zhijie Lee
# I didnot realize the image_download function
# but it's not very difficult,so that you can do it by yourself
#cmd usage:blogdownloader_csdn.py blogname "full directory path"
#further extension :classify the articles to
# "原创""转载" etc.according to csdn
import os
import sys
import unicodedata
import urllib.request
#globle var
username=sys.argv[1]
#username='onezeros'
#total number of pages
total_num=0
dst_urls=[]
#use data as the file name
dst_title=[]
###########################################
#function to find urls of articals
#it's neccessory to verify whether the url exits
def url_finder(url_directory,firstpage=False):
global username,total_num,dst_urls,dst_title
url_f=urllib.request.urlopen(url_directory)
print("open url "+url_directory+" successfully\n")
url_front='/'+username+'/archive/'
for line in url_f.readlines():
lin=line.decode('utf-8')
pos_front=lin.find(url_front)
if(pos_front!=-1 ):
pos_post=len('2009/12/13/4998191.aspx')+len(url_front)+pos_front
if(lin[pos_post]=='#'):
dst_urls.append('http://blog.csdn.net'+lin[pos_front:pos_post])
s=lin[pos_front+len(url_front):pos_post-len('.aspx')]
s=s.replace('/','-')
print(s)
dst_title.append(s)
if(firstpage==True):
pos=lin.find('第1页')
if(pos!=-1):
pt=lin.find('页',pos+5)
total_num=int(lin[pos+5:pt])
if(firstpage==True and total_num==0):
prin


相关文档:

用python连接mysql数据库


#
-*- encoding: gb2312 -*-
import
os, sys, string
import
MySQLdb
#
连接数据库
try
:
conn
=
MySQLdb.connect(host
=
'
localhost
'
,user
=
'
root
'
,passwd
=
'
xxxx
'
,db
=
'
test1
'
)
except
Exception, e:
print
e
sys.exit()
......

用python, c#, java写的文件拷贝

     前一段时间试着用这三种语言简单的写了关于文件拷贝的程序,发现c#和python的api惊人的相似,对于文件的操作这两种语言非常的方便。都没有加异常的处理
C#源代码:
        public static void CopyFile(string source, string destination)
  & ......

Python and RRD

RRD是Round Robin Database的意思,RRDTool是用来管理RRD的一个工具。RRDTool的主页在这里,Wikipedia的页面在这里。RRD其实就是一个时序数据库,使用一个固定大小的环型buffer,适用于存储一些统计性的信息,如CPU负载呀,气温变化呀。我为什么要说这个东西呢,因为XenServer里的性能统计是用的RRD,你可以访问诸如http:// ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号