Beispiel #1
0
    def __token_get(self):
        # 获取首页cookies
        urls = [
            'https://www.amazon.com/gp/goldbox?ref_=nav_cs_gb_azl',
            'https://www.amazon.com/b/ref=gc_surl_giftcards?node=2238192011',
            'https://www.amazon.com/ref=nav_logo',
            'https://www.amazon.com/gp/help/customer/display.html?nodeId=508510&ref_=nav_cs_help'
            'https://www.amazon.com/b/?_encoding=UTF8&ld=AZUSSOA-sell&node=12766669011&ref_=nav_cs_sell',
            'https://www.amazon.com/Outlet/b/?ie=UTF8&node=517808&ref_=sv_subnav_goldbox_3'
        ]
        url = choice(urls)
        self.request(url=url)
        tools.sleep(3)
        self.__change_cidy()
        if not self.session.cookies.get('ubid-main'):
            self.logger.warning('[%s]: %s Token Failed %s' %
                                (tools.current_time(), self.__zip_code, url))
            return None
        # 显示成功日志
        if self.__debug:
            self.logger.warning('[%s]: Token Success.' % tools.current_time())

        cookies = self.session.cookies
        cookies = self.dict_from_cookiejar(cookies)
        return cookies
Beispiel #2
0
    def run(self):
        web = Process(target=self.web)
        web.start()

        cookies = Process(target=self.cookies)
        cookies.start()

        goods = Process(target=self.goods)
        tools.sleep(60 * 5)  #等侍5分钟后启动 这几分钟可添加数据
        goods.start()
Beispiel #3
0
 def __proxies_set(self, is_set_proxy=False):
     """设置代理"""
     if self.__proxy_api and is_set_proxy:
         tools.sleep(2)
         ip = self.request(url=self.__proxy_api)
         if ip:
             self.session.proxies = {'http':ip, 'https':ip}
         else:
             self.logger.warning('[%s]: Get Porxies Failed!' % tools.current_time())
             self.session.proxies={}
     else: self.session.proxies = {}
Beispiel #4
0
 def __cookies_up(self):
     """
     更新Cookies
     :return:
     """
     token = sqlite.execute('select id,row from cookies limit 1').fetchone()
     if token:
         self.__token_id = token[0]
         cookies = json.loads(unquote(token[1]))
         self.session.cookies = self.cookiejar_from_dict(cookies)
         return True
     self.logger.warning('[%s]: 数据库中Cookie为空,等待600秒...'%tools.current_time())
     tools.sleep(600)
     return False
Beispiel #5
0
 def goods(self):
     n = 1  #计数
     i = [6, 9, 20, 11, 15]  # 为求随机
     api = 'http://127.0.0.1:1015/get?m=mina998'
     api = 'http://198.35.45.110:1015/get?m=mina998'
     obj = Goods(debug=debug, proxy_api=api)
     while True:
         if n % choice(i) == 0: is_proxy = False
         else: is_proxy = True
         # 下次运行时间(秒)
         if debug: exe = 600
         else: exe = tools.next_time_stamp() - tools.time_stamp_now(True)
         if obj.get(is_proxy) == 'ok': tools.sleep(exe)
         n += 1
Beispiel #6
0
 def cookies(self):
     while True:
         tools.sleep(5)
         obj = Cookies(zip=choice(zips), debug=debug)
         obj.get()