def createOpener(self): #%APPDATA%\Mozilla\Firefox\Profiles\ 火狐浏览器cookie位置 在运行里输入前面的地址即可跳转 cookiejar = sqlite2cookie.sqlite2cookie(conf.cookiesPath) cookie_support = urllib2.HTTPCookieProcessor(cookiejar) proxyAdd = self.proxys[random.randint(0,len(self.proxys)-1)] print proxyAdd proxy_handler = urllib2.ProxyHandler({"http":proxyAdd}) opener = urllib2.build_opener(cookie_support, proxy_handler, urllib2.HTTPHandler) urllib2.install_opener(opener)
def createOpener(self): #%APPDATA%\Mozilla\Firefox\Profiles\ 火狐浏览器cookie位置 在运行里输入前面的地址即可跳转 cookiejar = sqlite2cookie.sqlite2cookie(r"C:\Users\YJF\AppData\Roaming\Mozilla\Firefox\Profiles\cuge8g7g.default\cookies.sqlite") cookie_support = urllib2.HTTPCookieProcessor(cookiejar) proxyAdd = self.proxys[random.randint(0,len(self.proxys)-1)] print proxyAdd proxy_handler = urllib2.ProxyHandler({"http":proxyAdd}) opener = urllib2.build_opener(cookie_support, proxy_handler, urllib2.HTTPHandler) urllib2.install_opener(opener)
def createOpener(self): #%APPDATA%\Mozilla\Firefox\Profiles\ 火狐浏览器cookie位置 在运行里输入前面的地址即可跳转 cookiejar = sqlite2cookie.sqlite2cookie(conf.cookiesPath) cookie_support = urllib2.HTTPCookieProcessor(cookiejar) proxyAdd = self.proxys[random.randint(0, len(self.proxys) - 1)] print proxyAdd proxy_handler = urllib2.ProxyHandler({"http": proxyAdd}) opener = urllib2.build_opener(cookie_support, proxy_handler, urllib2.HTTPHandler) urllib2.install_opener(opener)
EXIT.set() time.sleep(1) print "------------------------------workers",len(WORKERS) for w in WORKERS: print "begin to invoke stop_main_loop" w.stop_main_loop() signal.signal(signal.SIGTERM, exit_handler) signal.signal(signal.SIGINT, exit_handler) ''' if __name__ == '__main__': print "-------------------------------------------------------------" print "begin", time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())) print sqlite2cookie.sqlite2cookie(conf.cookiesPath) sys.exit(1) bug = WeiBoBug() res = bug.getSearchList() #单进程执行 bug.createOpener() bug.wapLogIn() bug.weiBoWapSearchByList(res) #多进程 ''' p1 = Process(target=wrap, args=(WORKERS[0],res[0:20000],)) p1.daemon=True p2 = Process(target=wrap, args=(WORKERS[1], res[20000:40000],)) p2.daemon=True
print "signal handler called with signal ", signum, " ", WORKERS, " ", frame EXIT.set() time.sleep(1) print "------------------------------workers",len(WORKERS) for w in WORKERS: print "begin to invoke stop_main_loop" w.stop_main_loop() signal.signal(signal.SIGTERM, exit_handler) signal.signal(signal.SIGINT, exit_handler) ''' if __name__ == '__main__': print "-------------------------------------------------------------" print "begin", time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(time.time())) print sqlite2cookie.sqlite2cookie(conf.cookiesPath) sys.exit(1) bug = WeiBoBug() res = bug.getSearchList() #单进程执行 bug.createOpener() bug.wapLogIn() bug.weiBoWapSearchByList(res) #多进程 ''' p1 = Process(target=wrap, args=(WORKERS[0],res[0:20000],)) p1.daemon=True p2 = Process(target=wrap, args=(WORKERS[1], res[20000:40000],)) p2.daemon=True