--刚接触python2天,想快速上手,就写了个爬虫,写完之后,成就感暴增,用起来顺手多了。
1.源码
#coding=utf-8
import urllib
import re
class Page():
__slots__ = ('url', 'regex', 'arg' )
def __init__(this ,url ,regex ,arg ):
if not arg :
arg['download'] = False
arg['write'] = False
arg['outpath'] = ''
this.filter = Filter(url,{
'regex' : regex,
'custom' : arg['custom'] if arg.has_key('custom') else ''
})
this.url = url;
this.outpath = arg['outpath'] if arg.has_key('outpath') else ''
this.download =arg['download'] if arg.has_key('download') else False
this.write = arg['write'] if arg.has_key('wri