diff --git a/shizhan/mysql/bs_duanzi.py b/shizhan/mysql/bs_duanzi.py new file mode 100755 index 0000000..2fdb30f --- /dev/null +++ b/shizhan/mysql/bs_duanzi.py @@ -0,0 +1,98 @@ +#! /usr/bin/python +# -*- coding:utf-8 -*- + +import urllib2 +import re +from socket import error as SocketError +from cookielib import CookieJar +import tools +import ConnectMysql + +import time + + +class LF_WANGWEN: + + def __init__(self): + + self.baseUrl = 'http://m.budejie.com/text/' + self.tool = tools.Tool() + + + def wang(self, value): + try: + print '\n***** ' + self.baseUrl + ' *****' + + # proxy = urllib2.ProxyHandler({'http': '' + ip + ''}) + # opener = urllib2.build_opener(proxy) + + cj = CookieJar() + cookieHandle = urllib2.HTTPCookieProcessor(cj) + opener = urllib2.build_opener(cookieHandle) + + opener.addheaders = [ + # ('User-Agent', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36'), + # ('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'), + # ('Accept-Encoding', 'gzip, deflate, sdch'), + # ('Accept-Language', 'zh-CN,zh;q=0.8,en;q=0.6'), + # ('Cache-Control', 'max-age=0'), + # ('Connection', 'keep-alive'), + # ('Host', 'm.budejie.com') + ] + + url = self.baseUrl + str(value) + print url + o = opener.open(url, timeout=10) + d = o.read() + + pattern = re.compile('
(.*?)
.*?