×Ô¶¯ÏÂÔØ²¢±£´æ²©¿Í Python½Å±¾
лÁËÒ»¸ö×Ô¶¯ÏÂÔØÖ¸¶¨È˵IJ©¿ÍµÄ½Å±¾
Õâ¸ö½Å±¾ÊÇÓÃÀ´ÏÂÔØ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
Ïà¹ØÎĵµ£º
Posted on 18:40:00 by ÏþÔÂ and filed under Notepad++, Python
¡¡¡¡Notepad++ ÊÇÒ»¸ö¿ªÔ´µÄÎı¾±à¼Æ÷£¬¹¦ÄÜÇ¿´ó¶øÇÒʹÓ÷½±ã¡£±à¼ºÍµ÷ÊÔ Python ³ÌÐòʹÓÃʲô±à¼Æ÷»òÕß IDE ²»Í¬ÈËÓв»Í¬¼û½â¡£ÔÚ²»¿¼ÂÇʹÓõ÷ÊÔ¹¤¾ßµÄÇé¿öÏ£¬Vim »òÕß Emacs Óû§×ÔÈ»¿ÉÒÔÎÞÊÓÆäËû±à¼Æ÷£¬²»¹ýÔÚ Windows »·¾³Ï£¬Ê¹Óà Notepad++ Ö ......
python ÖеÄre Ä£¿é
ÕýÔò±í´ïʽ
¾Í¸öÈ˶øÑÔ£¬Ö÷ÒªÓÃËüÀ´×öһЩ¸´ÔÓ×Ö·û´®·ÖÎö£¬ÌáÈ¡ÏëÒªµÄÐÅÏ¢
ѧϰÔÔò£º¹»ÓþÍÐУ¬ÐèÒªµÄʱºòÔÚÉîÈë
ÏÖ×ܽáÈçÏ£º
ÕýÔò±í´ïʽÖÐÌØÊâµÄ·ûºÅ£º
“.” ±íÈÎÒâ×Ö·û
“^ ” ±ístringÆðʼ
“$” ±ístring ½áÊø
“*” “+” & ......
ǰһ¶Îʱ¼äÊÔ×ÅÓÃÕâÈýÖÖÓïÑÔ¼òµ¥µÄдÁ˹ØÓÚÎļþ¿½±´µÄ³ÌÐò£¬·¢ÏÖc#ºÍpythonµÄapi¾ªÈ˵ÄÏàËÆ£¬¶ÔÓÚÎļþµÄ²Ù×÷ÕâÁ½ÖÖÓïÑԷdz£µÄ·½±ã¡£¶¼Ã»ÓмÓÒì³£µÄ´¦Àí
C#Ô´´úÂ룺
public static void CopyFile(string source, string destination)
& ......
ÕâÊÇÒ»¸öÎÒÃÇÔÚ´¦ÀíÖÐÎÄʱ, ¾³£Óöµ½µÄÎÊÌâ.
pythonÀïÃæ»ù±¾ÉÏÒª¿¼ÂÇÈýÖÖ±àÂë¸ñʽ
1 Ô´Îļþ±àÂë
ÔÚÎļþÍ·²¿Ê¹ÓÃcodingÉùÃ÷¡£¸æËßpython½âÊÍÆ÷¸Ã´úÂëÎļþËùʹÓõÄ×Ö·û¼¯¡£
#/usr/bin/python
#coding: utf8
2 ÄÚ²¿±àÂë
´úÂëÎļþÖеÄ×Ö·û´®£¬¾¹ýdecodeÒԺ󣬱»×ª»»ÎªÍ³Ò»µÄunicode¸ñʽµÄÄÚ²¿Êý¾Ý£¬ÀàËÆÓÚu'*'¡£unic ......