Esempio n. 1
0
    def amil_code(self, dr, amil_num, login_wd):
        # 翻页后获得验证码输入框并输入

        vir = dr.find_element_by_xpath(
            '//*[@id="cvf-page-content"]/div/div/div[1]/form/div[2]/input')
        amil_wd = self.data_tool.get_reg_info('amil_wd', self.info_id)
        vir_code = get_vir_code(amil_num, amil_wd)
        if vir_code == 1:
            self.data_tool.update_info(2, '邮箱验证失败!', self.info_id)
            dr.quit()
            return
        else:
            vir.send_keys(vir_code)
            verifiter = dr.find_element_by_xpath('//*[@id="a-autoid-0"]')
            verifiter.click()

            html = dr.page_source
            name = self.data_tool.get_name(self.info_id)
            firstname = name.split(' ')[0]
            bonjour_name = 'Hello, ' + firstname
            if bonjour_name in html:

                # 更新用户状态码
                self.data_tool.update_info(1, login_wd, self.info_id)

                cookies = dr.get_cookies()
                with open("cookies.txt", "w") as fp:
                    json.dump(cookies, fp)
                self.data_tool.update_cookies(self.info_id)
                time.sleep(1)

                input_kw = dr.find_element_by_xpath(
                    '//*[@id="twotabsearchtextbox"]')
                key_word = make_data.get_kw()
                input_kw.send_keys(key_word)
                sub = dr.find_element_by_xpath(
                    '//*[@id="nav-search"]/form/div[2]')
                sub.click()
                # wait.until(EC.presence_of_element_located((By.ID, 'a-page')))
                num = 0

                try:
                    detail_node = dr.find_element_by_xpath(
                        '//*[@id="search"]/div[1]/div[2]/div/span[3]/div[1]/div[1]//h5/a'
                    )
                    detail_node.click()
                except:
                    print('获取商品详情页面失败')
                finally:
                    self.like_car(dr)

            else:
                self.data_tool.update_info(2, "邮箱已使用!", self.info_id)
                time.sleep(1)
                dr.quit()
                return
Esempio n. 2
0
    def sneak_away(self, dr):
        input_kw = dr.find_element_by_id("twotabsearchtextbox")
        k = make_data.get_kw()
        input_kw.send_keys(k)
        input_kw.send_keys(Keys.ENTER)

        try:
            dr.find_element_by_xpath(
                '//*[@id="search"]/div[1]/div[2]/div/span[3]/div[1]/div[{}]//h5/a'.format(random.randint(1, 3))).click()
            self.like_car(dr)
        except:
            print('点击商品详情失败!')

        return