def LotBet(lotType, termCode, money, ticketCount, dataList): global messageId messageId += 1 timeStamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) head = ('2001', agentInfo[0], str(messageId), timeStamp) body = '<body><lottype>' + lotType + '</lottype><periodical>' + termCode + '</periodical><money>' + money + '</money><ticketcount>' + ticketCount + '</ticketcount><datalist>' + dataList + '</datalist></body>' reqData = CommonFun.GetRequestXml(head, body, agentInfo[1]) betResult = CommonFun.HpptPost(ttUrl, reqData) return betResult
def GetPrizeInfo(lotType, termCode): global messageId messageId += 1 timeStamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) head = ('1002', agentInfo[0], str(messageId), timeStamp) body = '<body><lottype>' + lotType + '</lottype><periodical>' + termCode + '</periodical></body>' reqData = CommonFun.GetRequestXml(head, body, agentInfo[1]) prizeInfo = CommonFun.HpptPost(ttUrl, reqData) return prizeInfo
def GetTermList(lotType): global messageId messageId += 1 timeStamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) head = ('1001', agentInfo[0], str(messageId), timeStamp) body = '<body><lottype>' + lotType + '</lottype></body>' reqData = CommonFun.GetRequestXml(head, body, agentInfo[1]) termList = CommonFun.HpptPost(ttUrl, reqData) return termList
def premproxy(self): i = 1 browser = CommonFun.openMyWindow(True, True, 30) while i <= 19: url = "https://premproxy.com/socks-list/%s.htm" % i browser.get(url) time.sleep(10) proxies = CommonFun.checkHasProxy(browser) if proxies: CommonFun.insertDB(proxies) i = i + 1 browser.close()
def proxylistplus(self): i = 1 browser = CommonFun.openMyWindow(True, True, 30) while i <= 6: url = "https://list.proxylistplus.com/Fresh-HTTP-Proxy-List-%s" % i browser.get(url) time.sleep(5) proxies = CommonFun.checkHasProxy(browser) if proxies: CommonFun.insertDB(proxies) i = i + 1 browser.close()
def local(self): i = 0 browser = CommonFun.openMyWindow(False, True, 3) url = 'file:///C:/Users/Pains/Desktop/vipsocks.txt' while i < 3: browser.get(url) time.sleep(1) proxies = CommonFun.checkHasProxy(browser) if proxies: CommonFun.insertDB(proxies) i = i + 1 url = "file:///C:/Users/Pains/Desktop/vipsocks (%s).txt" % i break browser.close()
def NoticeDeal(reqCon): resCon = "ok" #调用解析出报文头和报文体 reqDetail = CommonFun.ResolveReqContent(reqCon) head = reqDetail[0] body = reqDetail[1] #判断通知类型 cmd = head[0] if (cmd == '2101'): body = GetBetNoticeBody(body) elif (cmd == '3002'): body = GetTicketInfoNoticeBody(body) else: pass resCon = CommonFun.GetRequestXml(head, body, agentInfo[1]) return resCon
def getProxyFromSubPage(browser, allLinks, subLinks): allHandles = browser.window_handles n = len(allHandles) for handle in allHandles: browser.switch_to_window(handle) result = checkHasProxy(browser) proxies = [] if result: for i in result: t = re.sub(r"\s", ':', i) proxies.append(t) insertDB(proxies) CommonFun.saveProxy(browser.current_url) links = getPageAllLink(browser) links = list(set(links).difference(set(allLinks))) subLinks = list(set(subLinks).union(set(links))) if n > 1: browser.close() n = n - 1 return subLinks
def spys(self): browser = CommonFun.openMyWindow(True, True, 100) urls = [ 'http://spys.one/en/free-proxy-list/', 'http://spys.one/free-proxy-list/US/', 'http://spys.one/en/anonymous-proxy-list/', 'http://spys.one/en/https-ssl-proxy/', 'http://spys.one/en/socks-proxy-list/', 'http://spys.one/en/http-proxy-list/', 'http://spys.one/en/non-anonymous-proxy-list/' ] for url in urls: browser.get(url) time.sleep(5) try: Select(browser.find_element_by_id('xpp')).select_by_index(5) time.sleep(4) proxies = CommonFun.checkHasProxy(browser) if proxies: CommonFun.insertDB(proxies) except: pass
def openMyWindow(useProxy=False, isHide=True): opts = Options() opts.add_argument("user-agent=%s" % CommonFun.getUa()) if isHide: opts.add_argument('--headless') opts.add_argument('--disable-gpu') if useProxy: opts.add_argument('--proxy-server=localhost:1080') driver = webdriver.Chrome(chrome_options=opts) driver.delete_all_cookies() driver.set_page_load_timeout(20) driver.set_script_timeout(20) return driver
def idcloak(self): url = 'http://www.idcloak.com/proxylist/proxy-list.html' browser = CommonFun.openMyWindow(True, True, 100) browser.get(url) time.sleep(5) i = 2 while i < 11: proxies = CommonFun.checkHasProxy(browser) if proxies: CommonFun.insertDB(proxies) items = browser.find_elements_by_css_selector('.pagination input') for item in items: if item.get_attribute('value') == str(i): try: item.click() except: try: item.send_keys(Keys.SPACE) except: pass break time.sleep(5) i = i + 1
def insertDB(proxies): cnn = CommonFun.getDBConnect() cursor = cnn.cursor() values = '' flag = False for i in proxies: if flag: values = values + ',' else: flag = True values = values + "('" + i + "', crc32('" + i + "'))" sql = "insert into proxy(proxy, proxy_crc) VALUES %s ON DUPLICATE KEY UPDATE proxy=VALUES(proxy) " % values print(sql) cursor.execute(sql) cnn.commit()
def Crawler(link): if CommonFun.hasProxied(link): print('had got it..') return 0 global cnt global lock lock.acquire() cnt = cnt - 1 lock.release() print("google: " + link) deep = 0 browser = openMyWindow(True) subCrawler(browser, [link], [link], deep) lock.acquire() cnt = cnt + 1 lock.release()
def socks24(self): url = 'http://www.socks24.org/search?max-results=15' browser = CommonFun.openMyWindow(True, True, 100) browser.get(url) time.sleep(10) items = browser.find_elements_by_css_selector('.entry-title a') for item in items: CommonFun.openMySubWindow(browser, item.get_attribute('href')) time.sleep(2) time.sleep(5) allHandles = browser.window_handles for handle in allHandles: browser.switch_to_window(handle) proxies = CommonFun.checkHasProxy(browser) if proxies: CommonFun.insertDB(proxies) browser.close()