zoukankan      html  css  js  c++  java
  • python 实现 知乎批量养号

    最近需要用到几个账户号,每天登录太麻烦,就写了一个脚本实现自动化登录,自动化浏览,自动化发回答,自动化点赞,以达到批量养号的目的

    微信 jiangfeng0103

    第一部 先登录

    #作者 微信 jiangfeng0103
        def login(self,account,driver):
            try:
                #Tab 切换
                target = driver.find_element_by_xpath("//div[@class='SignFlow-tab']")
                ActionClick = ActionChains(driver).click(target)
                time.sleep(2)
                ActionClick.perform()
                #输入 用户名
                username = driver.find_element_by_xpath("//input[@name='username']")
                username.send_keys(account['loginName'])
                time.sleep(1)
                # 输入密码
                password = driver.find_element_by_xpath("//input[@name='password']")
                password.send_keys(account['loginPwd'])
                time.sleep(1)
    
                target = driver.find_element_by_xpath("//button[@class='Button SignFlow-submitButton Button--primary Button--blue']")
                ActionClick = ActionChains(driver).click(target)
                time.sleep(1)
                ActionClick.perform()
                time.sleep(1)
                if self.checkTengxun(driver) == False:
                    WebDriverWait(driver, 20, 1).until(EC.presence_of_element_located((By.ID, 'tcaptcha_iframe')))  # 等待 iframe
                    driver.switch_to.frame(driver.find_element_by_id('tcaptcha_iframe'))  # 加载 iframe
                    self.captcha.re_start(driver)
                if self.checkYundun(driver) == False:
                    yd = yidun.yidun(driver)
                    yd.crack_slider()
                accountCheckResult = self.accountCheck(driver)
                if accountCheckResult == False:
                    return False
                target = driver.find_element_by_xpath("//button[@class='Button SignFlow-submitButton Button--primary Button--blue']")
                ActionClick = ActionChains(driver).click(target)
                time.sleep(1)
                ActionClick.perform()
                time.sleep(2)
                accountCheckResult = self.accountCheck(driver)
                if accountCheckResult == False:
                    return False
                return True
            except Exception as e:
                print("登录 异常 {}", format(e))

    第二步:完成自动化操作--自动上传头像

        
    #作者 微信 jiangfeng0103
    # 自动上传头像
        def autoUploadPhoto(self,driver):
            try:
                imgPath = os.path.abspath('.') + "\img\"
                for root, dirs, files in os.walk(imgPath):  
                    if len(files) == 0:
                        print("{} 暂无可用头像".format(datetime.datetime.now()))
                        return
                    if len(files) < 200:
                        print("{} 当前图片数量 {},请下载更多图片".format(datetime.datetime.now(),len(files)))
                    break
                target = driver.find_element_by_xpath("//img[@class='Avatar Avatar--large UserAvatar-inner']")
                src = target.get_attribute('src')
                if str(src).find("da8e974dc_xl") > -1:
                    print("{}  开始上传头像".format(datetime.datetime.now()))
                    time.sleep(2)
                    target = driver.find_element_by_xpath("//div[@class='Mask-content']")
                    ActionClick = ActionChains(driver).click(target)
                    ActionClick.perform()
                    time.sleep(5)
                    newPath = self.utils.cmdZhihuUploadPhoto()
                    time.sleep(8)
                    target = driver.find_element_by_xpath("//div[@class='ModalButtonGroup ModalButtonGroup--vertical']/button")
                    ActionClick = ActionChains(driver).click(target)
                    time.sleep(2)
                    ActionClick.perform()
                    print("{}  已上传".format(datetime.datetime.now()))
                    if self.uploadFinishRemovePhoto:
                        os.remove(newPath)
                    time.sleep(3)
            except Exception as e:
                print("{} 上传头像 异常 {}".format(datetime.datetime.now(),format(e)))
                time.sleep(1)
  • 相关阅读:
    关闭编辑easyui datagrid table
    sql 保留两位小数+四舍五入
    easyui DataGrid 工具类之 util js
    easyui DataGrid 工具类之 后台生成列
    easyui DataGrid 工具类之 WorkbookUtil class
    easyui DataGrid 工具类之 TableUtil class
    easyui DataGrid 工具类之 Utils class
    easyui DataGrid 工具类之 列属性class
    oracle 卸载
    “云时代架构”经典文章阅读感想七
  • 原文地址:https://www.cnblogs.com/Fengger/p/14789760.html
Copyright © 2011-2022 走看看