»°ËµPython£¨ËÄ£©»¶ÓСÂéȸ
С°×ÊǸö΢ÈíÃÔ£¬ËûµÄżÏñÊDZȶû´óÊ壬ÔÒòµ±È»ÊǵØÇòÈ˶¼ÖªµÀÀ²¡£´ó¶þµÄʱºò£¬ËûµÄ“ê¡Ñ§¼Æ»®”ÔøÒ»¶ÈµÃ³Ñ£¬ÔÒòÊÇËû¹Ò¿ÆÌ«¶à¡£µ±È»£¬´óÈýÐÂѧÆÚ¿ªÊ¼µÄʱºò£¬Ãæ¶Ô¹«ÖÚÖÊÒÉ£¬Ð¡°×Õ¾ÔÚÒÎ×ÓÉÏ£¬Ïñ¼«ÁË¡¶´óÄÚÃÜ̽ÁãÁã·¢¡·ÀïµÄÎ÷ÃÅ´µÑ©£º“ÊÀ½çÊ׸»±È²»Ò»¶¨Óжà³öÉ«£¬ÕâÖ»²»¹ýÊÇÄãÃÇÕâЩÐǶ·ÊÐÃñÒ»ÏáÇéÔ¸µÄÏë·¨°ÕÁË¡£”
ÿÌìС°×¶¼»áÔÚËÞÉáתÓÆ£¬ºÃÏñºÜ“¹Â¶À”£¬×ìÀïÄîÄîÓдʣº“Õâ¸öÊÀ½çÕýÔÚ·¢Éú×Å·Ì츲µØµÄ±ä»¯£¬¶øÎÒÃÇÈ´Ïñë¿ËƵÄÉú»î¡£”×îºó£¬Ëû×Ü»áÀ´Ò»¾ä£º“ÎÒÒª³ÉÁ¢µÚ¶þ¸ö¹È¸è£¡”
Õâ½Ú¿Î£¬ÎÒÃǾͻáÁ˽âËÑË÷ÒýÇ棬»¹»á±àдһ¸öСÐ͵ÄÍøÂçÅÀ³æ¡£
ËÑË÷ÒýÇæÓÐÄļ¸²¿·Ö¹¹³É£¿
Ê×ÏȸÐлÕâÕÅͼµÄÔ×÷Õߣ¬Ö÷Òª»¹ÊÇÒª¸ÐлCountry¡£Í¨¹ýÕâÕÅͼ£¬ÎÒÃÇ¿ÉÒÔ¿´µ½£ºÊ×ÏÈ£¬ÍøÂçÖ©ÖëץȡÍøÒ³£¬½«ÍøÒ³ÄÚÈݼ°Á´½Ó´æµ½Êý¾Ý¿âÖС£È»ºóÓÉË÷ÒýÄ£¿é½¨Á¢¹Ø¼ü´Êµ½ÍøÖ·µÄË÷Òý£¬¹©¼ìË÷Ä£¿é²éѯ¡£¼ìË÷Ä£¿éÊǸù¾ÝÄãÊäÈëµÄÄÚÈÝ´ÓË÷ÒýÊý¾Ý¿âÌáÈ¡Êý¾Ý¡£Ö÷Ҫģ¿é½éÉÜÈçÏ£º
Íøҳץȡģ¿é£º°üÀ¨CrawlerºÍCrawler control£¬ÆäÖÐCrawler¸ºÔðץȡ²¢·ÖÎöÍøÒ³Á´½Ó£¬·µ»ØpageºÍurl£»Crawler control¸ºÔð¿ØÖÆ¡¢µ÷¶ÈCrawler¡£
ÍøÒ³´æ´¢Ä£¿é:Page cache£¬ÓÃÓÚ´æ´¢Crawlerץȡµ½µÄÍøÒ³ÄÚÈÝ¡£
Ë÷ÒýÄ£¿é:½¨Á¢¹Ø¼ü´Êµ½Á´½ÓºÍÍøÒ³µÄË÷Òý¡£
¼ìË÷Ä£¿é£º½«Òª²éѯµÄÄÚÈÝ·Ö½âΪÊʺϲéѯµÄ´Ê¡£
Óû§½Ó¿Ú£º½ÓÊÜÓû§ÊäÈ룬´«µÝµ½¼ìË÷Ä£¿é¡£
½ÓÏÂÀ´µÄ¿Î³ÌÀïÎÒÃÇ»á¸ù¾ÝËùѧµÄPython֪ʶ¿ª·¢Ò»¸öСÐ͵ÄËÑË÷ÒýÇæ¡£Ãû×Ö½ÐSparrow¼´Âéȸ£¬Òâ˼ÊÇ“ÂéȸËäС£¬ÎåÔà¾ãÈ«”¡£ÎÒÃǵēÂéȸ”»áËæ×ÅÎÒÃÇ֪ʶµÄÔö¼Ó¶øÔ½·ÉÔ½¸ß£¬Ëµ²»¶¨»á±ä³É·ï»ËÄØ¡£µ±È»£¬ÏÖÔÚËü»¹Ã»ÓÐÆð·É¡£
ÈÃÎÒÃÇ¿ªÊ¼ËÑË÷ÒýÇæÖ®Âðɣ¡
Ê×ÏÈÎÒÃÇҪѧϰµÄÄ£¿éÊÇÍøҳץȡģ¿é£¨Crawler£©£¬ÓÖ½Ð×öÍøÂçÖ©Ö루Spider£©¡£
Õâ¸öÄ£¿éÓÉCrawlerÀàÀ´Íê³É£¬¸ÃÀà³õʼ»¯Ê±Ê×ÏȽÓÊÜCrawler controlÄ£¿é´«µÝµÄurl£¬Ö´ÐÐÍê±Ï×îºó·µ»ØÍøÒ³ÄÚÈÝpageºÍÍøÒ³ÄÚ³öÏÖµÄurlÁ´½Ólink¡£Ô´ÂëÈçÏ£º
import urllib.request #ÓÃÓÚ»ñÈ¡ÍøÒ³ÄÚÈÝ
import urllib.parse #½âÎöÍøÖ·µÄÄ£¿é
import re #ÕýÔò±í´ïʽ
import queue #²Ù×÷¶ÓÁеÄÄ£¿é
class Crawler(object): #ÍøÂç×
Ïà¹ØÎĵµ£º
import urllib
from HTMLParser import HTMLParser
class TitleParser(HTMLParser):
def __init__(self):
self.title = ''
self.divcontent = ''
self.readingtitle = 0
self.readingdiv = 0
HTMLParser.__init__(self)
def handle_starttag(self, tag, attrs):
......
1£¬ÏÂÔØorg.python.pydev.feature-1.5.0.1251989166.zip http://sourceforge.net/projects/pydev/files/
2£¬°²×°²å¼þµ½eclipse
3£¬ÖØÆôeclipse
×¢Ò⣺ʹÓÃ1.5.6°æ±¾pydev²å¼þ£¬´´½¨python¹¤³Ì»á±¨´í£¬Ê¹ÓÃ1.5.0°æ±¾ÎÞ´ËÎÊÌâ¡£ ......
pythonµÄ±ä²Î
*argsºÍ**dargsÊÇPythonµÄÁ½¸ö¿É
±ä²ÎÊý£¬Á½ÕßÓÐËù²»Í¬µÄÊÇ*argsÊǸötuple£¬**dargsÊǸödict¡£
*args
ºÍ**dargs²¢ÓÃʱ£¬*args±ØÐë·ÅÔÚ**dargsµÄÇ°Ãæ¡£
ÀýÈ磺
def func(a,b, *c):
pass
º¯ÊýfuncÖÁÉÙÓÐÁ½¸ö²ÎÊý±ä²ÎÊý·ÅÔÚtuple cÖÐ
def func(*c): »òÕß def func(**d ......
#from pp3e Chapter 9.3
#############################################################################
# popup three new window, with style
# destroy() kills one window, quit() kills all windows and app; top-level
# windows have title, icon, iconify/deiconify and protocol for wm events;
# there ......
ÒëÕßÑÔ£º
ÔçÔÚ 2008 Äê 8 Ô£¬ÎÒ¾ÍÔøÔÚ×Ô¼ºµÄ²©¿Í·¢±íÁËһƪ¡¶ÎªÊ²Ã´<Dive into Python>²»ÖµµÃÍƼö¡·£¨http://blog.csdn.net/lanphaday/archive/2008/08/28/2845258.aspx
£©£¬µ±Ê±ÒýÆðµÄÌÖÂ۾Ͳ»¶à˵ÁË£¬²»¹ýÊÂʵÉϵ½½ñÌìÈÔÈ»ÓÐÐí¶àÅóÓÑÁôÑÔÓëÎÒÌÖÂÛ£¬ÈÃÎÒ¼¸´ÎÔôÐIJ»ËÀ£¬ÏëдÔÙÉîÈëÅúÅС£ºÃÔ˵ÄʱºòÔÚÎÒÕæÕýÔÜ×㶯Á ......