def Get(self, url): try: self.init(url) if not self._connection: if self._port == '80': self._connection = httplib.HTTPConnection(self._host) else: self._connection = httplib.HTTPConnection( self._host, self._port) self._connection.request( 'GET', self._path, headers={ "Cookie": "BAIDUID=1C28E8F769E41C8AE695D327468BC3A6:FG=1", "User-Agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1) Gecko/20090624 Firefox/3.5", "Accept": "text/plain" }) response = self._connection.getresponse() status = response.status data = response.read() header = response.getheader('location') self._connection.close() xtslog.info('check status : ' + str(status) + '\t' + str(url)) if status == 302 or status == 301: re_status = self.Get(header) except Exception, e: xtslog.info("Failed", url) print "failed " + url + " " + str(e) return 0, 0, 0
def Send_url(self, bfp_c, bfp_url): try: result = self.Get(bfp_url + bfp_c)[2] xtslog.info(result) qn_pos = result.find('qn') if qn_pos == -1: return 0, 0 qn_num = result[qn_pos + 7:qn_pos + 23] adcacheurl = 'http://cq01-testing-cbbs-vir06.vm.baidu.com:8098/bfp/snippetcacher.php?qn=' if qn_num == "CPRO_SETJSONADSL": return 0, 0 tmp_result = self.Get(adcacheurl + qn_num)[2] #stat = self.Get(self.getck_xx(tmp_result)) result = self.geturl("curl", tmp_result) + self.geturl( "noticeurl", tmp_result) result = "{" + result + "}" result_dict = eval(result) for one in result_dict["noticeurl"]: stat_0 = self.Get(one) xtslog.info('send win notice url: %s %s' % (str(stat_0[0]), str(one))) import random if random.randint(0, 100) < 10: stat = self.Get(result_dict["curl"]) xtslog.info('send click url: %s %s' % (str(stat[0]), str(result_dict["curl"]))) except: return 0, 0
def Send_url(self, bfp_c, bfp_url): try: result = self.Get(bfp_url + bfp_c)[2] xtslog.info(result) qn_pos = result.find('qn') if qn_pos == -1: return 0, 0 qn_num = result[qn_pos + 7 : qn_pos + 23] adcacheurl='http://cq01-testing-cbbs-vir06.vm.baidu.com:8098/bfp/snippetcacher.php?qn=' if qn_num == "CPRO_SETJSONADSL": return 0,0 tmp_result = self.Get(adcacheurl + qn_num)[2] #stat = self.Get(self.getck_xx(tmp_result)) result = self.geturl("curl",tmp_result) + self.geturl("noticeurl",tmp_result) result = "{" + result + "}" result_dict = eval(result) for one in result_dict["noticeurl"]: stat_0 = self.Get(one) xtslog.info('send win notice url: %s %s'%(str(stat_0[0]), str(one))) import random if random.randint(0,100) <10: stat = self.Get(result_dict["curl"]) xtslog.info('send click url: %s %s'%(str(stat[0]), str(result_dict["curl"]))) except: return 0,0
def Get(self, url): try: self.init(url) if not self._connection: if self._port == '80': self._connection = httplib.HTTPConnection(self._host) else: self._connection = httplib.HTTPConnection(self._host, self._port) self._connection.request('GET', self._path,headers={"Cookie":"BAIDUID=1C28E8F769E41C8AE695D327468BC3A6:FG=1","User-Agent":"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1) Gecko/20090624 Firefox/3.5","Accept": "text/plain"}) response = self._connection.getresponse() status = response.status data = response.read() header = response.getheader('location') self._connection.close() xtslog.info('check status : ' + str(status) + '\t' + str(url)) if status == 302 or status == 301: re_status = self.Get(header) except Exception, e: xtslog.info("Failed", url) print "failed " + url + " " + str(e) return 0,0,0