def get_authenticity_token(userData):
    try:
        headers = {
            'Host': 'www.sbnation.com',
            'User-Agent':
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36',
            'Accept':
            'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
            'Referer':
            'https://www.sbnation.com/users/' + userData['username'],
            'Cookie': '_session_id=' + userData['cookie'],
        }
        url = 'https://www.sbnation.com/users/' + userData[
            'username'] + '/edit_profile'
        res = requestsW.get(url, proxies=ip_proxy("en"), headers=headers)
        if res == -1:
            return -1, -1
        token_list = re.findall('name="authenticity_token" value="(.*?)" />',
                                res.text)
        if not token_list:
            g_var.logger.info('获取修改个人网址的authenticity_token失败。。。')
            return -2, -2
        session_list = re.findall('_session_id=(.*?);',
                                  res.headers['Set-Cookie'])
        if not session_list:
            g_var.logger.info('获取修改个人网址的session_id失败。。。')
            return -2, -2
        return token_list[0], session_list[0]
    except Exception as e:
        g_var.logger.info(e)
        g_var.ERR_CODE = 5000
        g_var.ERR_MSG = "获取authenticity_token出现异常..."
        g_var.logger.info("获取authenticity_token出现异常...")
        return -2, -2
def get_session_id():
    try:
        headers = {
            'accept':
            'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
            'user-agent':
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36',
        }
        url = 'https://auth.voxmedia.com/signup?return_to=https://www.sbnation.com/'
        res = requestsW.get(url,
                            proxies=ip_proxy("en"),
                            headers=headers,
                            timeout=g_var.TIMEOUT)
        if res == -1:
            return res
        str_session = res.headers['Set-Cookie']
        if not str_session:
            g_var.logger.info('获取session_id值失败。。。')
            return -2
        list_session = str_session.split(';')
        if not list_session:
            g_var.logger.info('获取_session_id值失败。。。')
            return -2
        return list_session[0]
    except Exception as e:
        g_var.logger.info(e)
        g_var.ERR_CODE = 5000
        g_var.ERR_MSG = "获取session_id出现异常..."
        g_var.logger.info("获取session_id出现异常...")
        return -2
def get_authenticity_token_signup():
    try:
        url = 'https://genius.com/signup'
        res = requestsW.get(url,
                            proxies=ip_proxy('ch'),
                            timeout=g_var.TIMEOUT,
                            vpn='ch')
        if res == -1:
            return 0, 0, 0
        token_list = re.findall(
            'name="authenticity_token" type="hidden" value="(.*?)" /></div>',
            res.text)
        res_headers = json.dumps(dict(res.headers))
        csrf_token_list = re.findall('_csrf_token=(.*?);', res_headers)
        session_list = re.findall('_rapgenius_session=(.*?);', res_headers)
        if not token_list or not csrf_token_list or not session_list:
            g_var.ERR_CODE = "2001"
            g_var.ERR_MSG = g_var.ERR_MSG + "|_|" + "获取注册authenticity_token值或_csrf_token值或_rapgenius_session值失败。。。"
            g_var.logger.info(
                '获取注册authenticity_token值或_csrf_token值或_rapgenius_session值失败。。。'
            )
            return -1, -1, -1
    except:
        g_var.logger.info("访问注册页失败。。。")
        return -1, -1, -1
    return token_list[0], csrf_token_list[0], session_list[0]
Exemple #4
0
def get_tok_email(url):
    try:
        res = requestsW.get(url, proxies=ip_proxy("en"), timeout=g_var.TIMEOUT)
        if res == -1:
            return res
        tok = re.findall('<input type=hidden name=tok value=(.*?) /></form>',
                         res.text)
        if not tok:
            g_var.logger.info("未获取到邮箱验证的tok...")
            return -2
        return tok[0]
    except Exception as e:
        g_var.logger.info(e)
        g_var.ERR_CODE = 5000
        g_var.ERR_MSG = "获取邮箱验证的tok出现异常..."
        g_var.logger.info("获取邮箱验证的tok出现异常...")
        return -2
def get_googlekey():
    try:
        url = 'https://login.ex.co/signup'
        res = requestsW.get(url)
        k_value = re.findall("window.pbRecaptchaSiteKey = '(.*?)';", res.text)
        if k_value:
            return k_value[0]
        else:
            g_var.ERR_CODE = 2001
            g_var.ERR_MSG = "使用当前代理无法获取googlekey值..."
            g_var.logger.error("使用当前代理无法获取googlekey值...")
            return -1
    except Exception as e:
        g_var.ERR_CODE = 2005
        g_var.ERR_MSG = g_var.ERR_MSG + "|_|" + "googlekey值出现异常!"
        g_var.logger.error("googlekey值出现异常!")
        g_var.logger.info(e)
        return -1
def register() -> (str, str, str):
    user = project_util.generate_random_string(12, 16)
    pwd = project_util.generate_random_string(10, 12)
    email = user + "@qq.com"
    dicproxy = ip_proxy()
    s = requests.session()
    s.proxies = dicproxy
    s.headers = headers
    proxies = ip_proxy()

    res = requestsW.get(
        "https://www.reddit.com/register/?actionSource=header_signup",
        proxies=proxies,
        headers=headers,
        timeout=5)
    cookies = res.cookies.get_dict()
    print(cookies)
    print("已经响应", res)
    re_res = re.search('<input type="hidden" name="csrf_token" value="(.*?)">',
                       res.text)
    csrf_token = re_res.group(1)
    print("正在打码中")
    # g_recaptcha_response = captcha()
    g_recaptcha_response = "03AGdBq24tyZjh-Ini2ud5ISBy1Eb-UYEpSKYdgxsNNLLvMRQT4VXCVW4Z1EuXrtX4GwlERbjJkS1x9cJtcPbKmGYwzvqRfajGUvFyq9CEfRSzohkPv54Lnk1BlU3OHE8suDOSrKwc90uj7TPeTL12VUhdyCk-H73quiajTYNuwd3pJm1xdWbbo4JthN8N0hvMIrsdM7_XYAclp_BN9QTWkwmhjDTpR8-CM2zWJ48JKug-9KZzaVM-Bmxzb7LVr4NcG5XozTrhsIdbS89eLSo8aoS7V-frd8Hb6xFpBpvjtsCQMnE25FoR7FqPmL2ER0bNV7QgowFX6Z8OFZ95fDDTub5S9qCQUr7Zactpz57_W38T6opn4u4swVH_EcEGUpkT1IhUgy5GVVsBgvidVR3F0j7F5tfLQ2_GKg"
    print("打印验证码:", g_recaptcha_response)

    data = {
        "csrf_token": csrf_token,
        "g-recaptcha-response": g_recaptcha_response,
        "dest": "https://www.reddit.com",
        "password": pwd,
        "username": user,
        "email": email,
    }
    # res.headers["content-type"]="application/x-www-form-urlencoded"

    res = requestsW.post("https://www.reddit.com/register",
                         headers=headers,
                         proxies=proxies,
                         cookies=cookies,
                         data=data,
                         timeout=5)
    print(res.cookies)
    print("注册结果:", res.text)
Exemple #7
0
def google_captcha(Session, googlekey, pageurl):
    """
    谷歌人机验证
    :param Session: Session对象
    :param googlekey: googlekey
    :param pageurl: 页面url
    :return: 谷歌人机验证结果
    """
    data = {
        'key': g_var.VERIFY_KEY2,
        'method': 'userrecaptcha',
        'googlekey': googlekey,
        'pageurl': pageurl,
    }
    url_captcha = g_var.VERIFY_URL2 + '/in.php'
    try:
        res = requests.get(url_captcha, params=data)
    except:
        g_var.logger.info("打码平台请求失败")
        return -1
    if "|" not in res.text:
        g_var.logger.info("谷歌验证出现问题" + str(res.text))
        return -1
    id_code = res.text.split("|")[1]
    url_code = g_var.VERIFY_URL2 + "/res.php?key=" + g_var.VERIFY_KEY2 + "&action=get&id=" + id_code
    while True:
        try:
            r = requestsW.get(url_code, timeout=g_var.TIMEOUT)
        except:
            g_var.logger.info("打码平台请求成功,查询可用key值失败")
            return -1
        if r != -1:
            if r.text == "CAPCHA_NOT_READY":
                g_var.logger.info("谷歌人机验证,等待15s" + r.text)
                time.sleep(15)
            else:
                if "|" in r.text:
                    g_var.logger.info("谷歌人机验证,成功:" + r.text.split("|")[1])
                    return r.text.split("|")[1]
                else:
                    g_var.logger.info("谷歌人机验证,出现问题:" + r.text)
                    return -1
        else:
            return -1
Exemple #8
0
def get_postarticle_tok(uid):
    try:
        url_tok = 'https://www.liveinternet.ru/journal_post.php?journalid=' + uid
        response = requestsW.get(url_tok, proxies=ip_proxy("en"))
        if response == -1:
            return -1
        result = re.findall(
            '<input type=hidden name=tok value=(.*?) /></form>', response.text)
        if not result:
            g_var.logger.info("未获取到文章发布页tok...")
            return -2
        tok = result[0]
        return tok
    except Exception as e:
        g_var.logger.info(e)
        g_var.ERR_CODE = 5000
        g_var.ERR_MSG = "获取文章发布页tok出现异常..."
        g_var.logger.info("获取文章发布页tok出现异常...")
        return -2
Exemple #9
0
    def __register_one(self, present_website, email_info):

        g_var.logger.info("register...")
        headers = generate_headers(0)
        if headers == -1:
            g_var.logger.info("获取注册headers失败...")
            return -2

        registerData = generate_register_data(present_website, email_info)
        g_var.logger.info(registerData)
        if registerData == -1:
            g_var.logger.info("未生成正确注册数据...")
            return -2

        url_register = 'https://www.wattpad.com/signup?nextUrl=/home'
        g_var.logger.info("提交注册中...")
        html = requestsW.post(url_register,
                              proxies=ip_proxy("en"),
                              data=registerData,
                              headers=headers,
                              timeout=g_var.TIMEOUT)
        if html == -1:
            return -1
        # 注册成功与否验证
        prove_info = 'Hi @' + registerData['username']
        if prove_info not in html.text:
            g_var.logger.info(html.text)
            g_var.logger.info("IP被封等原因...")
            return -2
        token_list = re.findall('token=(.*?);', html.headers['Set-Cookie'])
        del headers['Origin']
        del headers['Content-Type']
        del headers['Referer']
        time.sleep(2)
        verify_url = get_verify_url(email_info)
        if verify_url == -1:
            g_var.logger.info("未读取到邮箱验证的url...")
            return -3
        g_var.logger.info("邮件的url正在验证中...")
        html = requestsW.get(url=verify_url,
                             proxies=ip_proxy("en"),
                             headers=headers,
                             timeout=g_var.TIMEOUT)
        if html == -1:
            return -1
        if html.status_code == 200:
            sql = "INSERT INTO wattpad_com(username, password, mail, status) VALUES('" + registerData['username'] + \
                  "', '" + registerData['password'] + "', '" + registerData['email'] + "', '" + str(0) + "');"
            last_row_id = MysqlHandler().insert(sql)
            if last_row_id != -1:
                registerData["id"] = last_row_id
                registerData["token"] = token_list[0]
                return registerData
            else:
                g_var.ERR_CODE = 2004
                g_var.ERR_MSG = "数据库插入用户注册数据失败..."
                g_var.logger.error("数据库插入用户注册数据失败...")
                return 0
        else:
            g_var.ERR_CODE = 3006
            g_var.ERR_MSG = "邮箱验证失败..."
            g_var.logger.error("邮箱验证失败!\n")
            return -3
Exemple #10
0
    def __register_one(self, Session, present_website: str, email_and_passwd):
        """
        注册一个账户
        Args:
            Session:Session对象
            present_website:当前网站名,用于数据库表名
            email_and_passwd:邮箱账户和密码,email_and_passwd[0]是邮箱,[1]是密码
        Returns:
            注册成功返回注册数据字典对象registerData,需要包含user_id, username, password, email
                user_id这样获取:(示例)
                    # 将注册的账户写入数据库(sql自己写,这边只是个示例)
                    sql = "INSERT INTO "+present_website+"(username, password, mail, status) VALUES('" + name + \
                          "', '" + psd + "', '" + email_and_passwd[0] + "', '" + str(0) + "');"
                    last_row_id = MysqlHandler().insert(sql)
                    if last_row_id != -1:
                        registerData["id"] = last_row_id
                        return registerData
                    else:
                        g_var.logger.error("数据库插入用户注册数据失败")
                        return 0
            注册失败返回状态码
            0:更换email 返回0 或其他错误,但是激活失败或插入数据库失败
            -1:表示requests请求页面失败,需要更换代理
            -2:注册失败,可能是邮箱密码不符合要求、或ip被封等原因,需要排查
        """

        user = project_util.generate_random_string(12, 16)
        pwd = project_util.generate_random_string(10, 12)
        email_list = email_and_passwd
        if email_list == -1:
            g_var.SPIDER_STATUS = 2
            g_var.ERR_MSG = g_var.ERR_MSG + "|_|NO email"
            g_var.logger.info("NO email")
            return 0

        verify_email = Session.get(
            "https://www.diigo.com/user_mana2/check_email?email=" +
            email_list[0],
            timeout=g_var.TIMEOUT,
            headers=self.headers,
            proxies=Session.proxies)  # 验证邮箱是否可用

        verify_user = Session.get(
            "https://www.diigo.com/user_mana2/check_name?username="******"1":
            g_var.SPIDER_STATUS = 2
            g_var.ERR_MSG = g_var.ERR_MSG + "|_|账号密码或邮箱已经被注册"
            g_var.logger.info("账号密码或邮箱已经被注册")
            return 0

        # time.sleep(3)

        google_captchas = google_captcha(
            "", "6Ld23sMSAAAAALfyXkI9d0nHmzOH9jZZNuh66nql",
            "https://www.diigo.com/sign-up?plan=free")
        if google_captchas == -1:
            g_var.SPIDER_STATUS = 2
            g_var.ERR_MSG = g_var.ERR_MSG + "|_|谷歌打码失败"
            g_var.logger.info("谷歌打码失败")
            return -2

        res = requestsW.get("https://www.diigo.com/",
                            headers=self.headers,
                            proxies=Session.proxies)  # 打开首页
        if res == -1: return res
        cookies = res.cookies.get_dict()
        i = 0
        while i < g_var.ERR_COUNT:
            i += 1
            try:
                Session.proxies = ip_proxy()
                res = requests.get("https://www.diigo.com/sign-up?plan=free",
                                   headers=self.headers,
                                   cookies=cookies,
                                   proxies=Session.proxies,
                                   verify=False)
                user_input = re.search('id="username" name="(\w{32})">',
                                       res.text)
                email_input = re.search('id=\'email\' name="(\w{32})">',
                                        res.text)
                pwd_input = re.search('id=\'password\' name="(\w{32})"',
                                      res.text)
                if not user_input and email_input and pwd_input:  # TODO 获取不到参数
                    return "注册无法打开网页"
                else:
                    user_input = user_input.group(1)
                    email_input = email_input.group(1)
                    pwd_input = pwd_input.group(1)
                data = {
                    "plan": "free",
                    "g-recaptcha-response": google_captchas,
                    user_input: user,
                    email_input: email_and_passwd[0],
                    pwd_input: pwd,
                }
                self.headers["X-Requested-With"] = "XMLHttpRequest"
                self.headers[
                    "Referer"] = "https://www.diigo.com/sign-up?plan=free"
                self.headers[
                    "Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"

                res = requests.post(
                    "https://www.diigo.com/user_mana2/register_2",
                    headers=self.headers,
                    cookies=cookies,
                    data=data,
                    proxies=Session.proxies,
                    verify=False)
                print(res.json())
                if project_util.dictExistValue(res.json(), "status"):
                    if res.json()["status"] == 1:
                        cookies.update(res.cookies.get_dict())
                        savec = cookies
                        res = requestsW.post(
                            "https://www.diigo.com/user_mana2/resend_verify",
                            cookies=cookies,
                            headers=self.headers,
                            data={"email": email_and_passwd[0]},
                            proxies=Session.proxies)
                        print("重新发送邮箱:", res.text)

                        emailinfo = EmailVerify(
                            email_and_passwd[0], email_and_passwd[1],
                            'href="(https://www.diigo.com/user_mana2/register_verify/\w{32})"'
                        ).execute_Start()
                        print("这里是邮箱参数:", emailinfo)
                        if emailinfo["data"] != -1:
                            Session = requestsW.session()
                            res = Session.get(emailinfo["data"],
                                              headers=self.headers,
                                              proxies=Session.proxies,
                                              cookies=cookies)
                            sql = """INSERT INTO %s (username, password, mail, status, cookie) VALUES("%s", "%s", "%s", "%s", "%s");""" % (
                                "diigo_com", user, pwd, email_and_passwd[0], 0,
                                savec)
                            g_var.logger.info(sql)
                            last_row_id = MysqlHandler().insert(sql)

                            if last_row_id != -1:
                                registerData = {
                                    "username": user,
                                    "password": pwd,
                                    "email": email_and_passwd[0],
                                    "cookie": savec,
                                }
                                registerData["id"] = int(last_row_id)
                                return registerData
                            return {
                                "user": user,
                                "pwd": pwd,
                                "email": email_and_passwd[0],
                                "cookies": Session.cookies.get_dict()
                            }
                            # if project_util.dictExistValue(res.cookies.get_dict(),"diigoandlogincookie"):  # 注册成功并登陆cookie
                            #     saveCookie = str(Session.cookies.get_dict())
                            #     # print({"user": user, "pwd": pwd, "email": email_and_passwd[0], "cookies": saveCookie})
                            #     return {"user": user, "pwd": pwd, "email": email_and_passwd[0], "cookies": saveCookie}
                    elif res.json()["status"] == -2:
                        if "captcha error" in res.json()["status"]:
                            g_var.SPIDER_STATUS = 2
                            g_var.ERR_MSG = g_var.ERR_MSG + "|_|谷歌打码失败"
                            g_var.logger.info("谷歌打码失败")
                            return -2
                return -2

            except Exception as e:
                res = requestsW.get("https://www.diigo.com/",
                                    headers=self.headers,
                                    proxies=Session.proxies,
                                    verify=False)  # 打开首页
                cookies = res.cookies.get_dict()
                g_var.logger.info(e)
                g_var.logger.info("正在换ip", e)
        return 0
def register_one(Session=None) -> dict:
    MysqlHandler().startDB()
    if Session == None:
        Session = requests.session()
        Session.proxies = ip_proxy()
    res = requestsW.get("https://www.diigo.com/",
                        headers=headers,
                        proxies=ip_proxy(),
                        verify=False)  #打开首页
    cookies = res.cookies.get_dict()
    print("这里是cookies", cookies)
    str_cookies = str(res.cookies.get_dict())
    cookies = eval(str_cookies)

    user = project_util.generate_random_string(12, 16)
    pwd = project_util.generate_random_string(10, 12)

    email_and_passwd = get_email("https://www.diigo.com")
    if email_and_passwd == -1:
        return "NO email"
    else:
        print("这里是邮箱", email_and_passwd)

    verify_user = requestsW.get(
        "https://www.diigo.com/user_mana2/check_name?username="******"https://www.diigo.com/user_mana2/check_email?email=" +
        email_and_passwd[0],
        cookies=cookies,
        headers=headers,
        proxies=Session.proxies,
        verify=False)  #验证邮箱是否可用
    if not verify_user.text == verify_email.text == "1":
        print("错误")
        return "账号密码或邮箱已经被注册"
    # time.sleep(3)

    google_captchas = google_captcha(
        "", "6Ld23sMSAAAAALfyXkI9d0nHmzOH9jZZNuh66nql",
        "https://www.diigo.com/sign-up?plan=free")
    # google_captchas ="google_captchas"
    if google_captchas == -1:
        return "谷歌打码失败"

    # requestsW.get("https://www.diigo.com/interact_api/load_user_premium_info",headers=headers,cookies=cookies,proxies=Session.proxies,verify=False)#必须访问
    i = 0
    while i < 20:
        try:
            Session.proxies = ip_proxy()
            res = requests.get("https://www.diigo.com/sign-up?plan=free",
                               headers=headers,
                               cookies=cookies,
                               proxies=Session.proxies,
                               verify=False)
            user_input = re.search('id="username" name="(\w{32})">', res.text)
            email_input = re.search('id=\'email\' name="(\w{32})">', res.text)
            pwd_input = re.search('id=\'password\' name="(\w{32})"', res.text)
            if not user_input and email_input and pwd_input:  # TODO 获取不到参数
                return "注册无法打开网页"
            else:
                user_input = user_input.group(1)
                email_input = email_input.group(1)
                pwd_input = pwd_input.group(1)
            data = {
                "plan": "free",
                "g-recaptcha-response": google_captchas,
                user_input: user,
                email_input: email_and_passwd[0],
                pwd_input: pwd,
            }
            headers["X-Requested-With"] = "XMLHttpRequest"
            headers["Referer"] = "https://www.diigo.com/sign-up?plan=free"
            headers[
                "Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8"
            print("准备提交")
            print(cookies)
            res = requests.post("https://www.diigo.com/user_mana2/register_2",
                                headers=headers,
                                cookies=cookies,
                                data=data,
                                proxies=Session.proxies,
                                verify=False)
            print(res.json())
            if project_util.dictExistValue(res.json(), "status"):
                if res.json()["status"] == 1:
                    cookies.update(res.cookies.get_dict())
                    savec = cookies
                    res = requestsW.post(
                        "https://www.diigo.com/user_mana2/resend_verify",
                        cookies=cookies,
                        headers=headers,
                        data={"email": email_and_passwd[0]},
                        proxies=Session.proxies)
                    print("重新发送邮箱:", res.text)

                    emailinfo = MyEmail(
                        email_and_passwd[0], email_and_passwd[1],
                        'href="(https://www.diigo.com/user_mana2/register_verify/\w{32})"'
                    ).execute_Start()
                    print("这里是邮箱参数:", emailinfo)
                    if emailinfo["data"] != -1:
                        Session = requestsW.session()
                        res = Session.get(emailinfo["data"],
                                          headers=headers,
                                          proxies=Session.proxies,
                                          cookies=cookies)
                        sql = """INSERT INTO %s (username, password, mail, status, cookie) VALUES("%s", "%s", "%s", "%s", "%s");""" % (
                            "diigo_com", user, pwd, email_and_passwd[0], 0,
                            savec)
                        g_var.logger.info(sql)
                        last_row_id = MysqlHandler().insert(sql)

                        if last_row_id != -1:
                            registerData = {
                                "username": user,
                                "password": pwd,
                                "email": email_and_passwd[0],
                            }
                            registerData["user_id"] = last_row_id
                            return registerData
                        return {
                            "user": user,
                            "pwd": pwd,
                            "email": email_and_passwd[0],
                            "cookies": Session.cookies.get_dict()
                        }
                        # if project_util.dictExistValue(res.cookies.get_dict(),"diigoandlogincookie"):  # 注册成功并登陆cookie
                        #     saveCookie = str(Session.cookies.get_dict())
                        #     # print({"user": user, "pwd": pwd, "email": email_and_passwd[0], "cookies": saveCookie})
                        #     return {"user": user, "pwd": pwd, "email": email_and_passwd[0], "cookies": saveCookie}
            return "res:" + res.text
        except (ConnectTimeout, ReadTimeout, ConnectionError) as e:
            res = requestsW.get("https://www.diigo.com/",
                                headers=headers,
                                proxies=Session.proxies,
                                verify=False)  # 打开首页
            cookies = res.cookies.get_dict()
            i += 1
            print(e)
            print("正在换ip", e)
Exemple #12
0
    def __postMessage(self, userData, present_website):
        """
        发文章
        Args:
            Session:Session对象
            loginData:用户信息,包括user_id,username,password,cookie
            present_website:当前网站名,用于数据库表名
        Returns:
            成功返回:"ok"
            失败返回状态值:
                1:跳出循环,重新取号
                0:cookie失效,将cookie清空,跳出循环重新取号
                -1:连续代理错误或页面发生改变等取不到关键数据等,需要停止程序
                -2:本次出错,继续循环
        """
        g_var.logger.info("post article ...")
        headers = generate_headers(0)
        if headers == -1:
            g_var.logger.info("获取headers失败...")
            return -1

        g_var.logger.info("article ...")
        article = get_new_article()
        if article == -1:
            return -2
        content = get_code_content(article[1])
        if content == -2:
            return -2

        g_var.logger.info("postarticle_tok ...")
        uid_upwd = userData['cookie'].split('|_|')
        postarticle_tok = get_postarticle_tok(uid_upwd[0])
        if postarticle_tok == -1:
            return -1
        elif postarticle_tok == -2:
            return -2

        g_var.logger.info("new_article_Id ...")
        new_article_Id = get_newarticle_Id(uid_upwd, article[0], headers)
        if new_article_Id == -1:
            return -1
        elif new_article_Id == -2:
            return -2
        elif new_article_Id == 1:
            return 1
        headers['Origin'] = 'https://www.liveinternet.ru'
        headers[
            'Referer'] = 'https://www.liveinternet.ru/journal_post.php?journalid=' + uid_upwd[
                0]
        headers['Cookie'] = 'bbuserid=' + uid_upwd[
            0] + '; bbpassword='******'action': 'newpost',
                'parsing': '',
                'journalid': uid_upwd[0],
                'backurl': '',
                'selectforum': '/journal_post.php?journalid=' + uid_upwd[0],
                'headerofpost': article[0],
                'mode': str(0),
                'status': 'Use these controls to insert vBcode',
                'LiNewPostForm': content,  # 文章内容
                'tags': article[-1],  # 标签
                'uploader_count': str(0),
                'music': '',
                'mood': '',
                'attachfile1': ("", '', 'application/octet-stream'),
                'MAX_FILE_SIZE': '',
                'nocomment': str(0),
                'commentsubscribe': 'yes',
                'parseurl': 'yes',
                'autosave_postid': new_article_Id,  # blog ID
                'close_level': str(0),
                'tok': postarticle_tok,
            },
            boundary='------WebKitFormBoundary' + generate_random_string(
                16, 16,
                'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'),
        )
        headers['Content-Type'] = multipart_encoder.content_type
        g_var.logger.info("正在发布文章 ...")
        url_article = 'https://www.liveinternet.ru/journal_addpost.php'
        html = requestsW.post(url_article,
                              proxies=ip_proxy("en"),
                              data=multipart_encoder,
                              headers=headers)
        if html == -1:
            return -1
        # 发布成功与否验证
        prove = 'Вы добавили сообщение в Ваш дневник'
        if prove not in html.text:
            g_var.ERR_CODE = 5000
            g_var.ERR_MSG = "文章发送失败,IP异常等原因..."
            g_var.logger.info('文章发送失败,IP异常等原因...')
            return 0
        del headers['Origin']
        headers[
            'Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9'
        g_var.logger.info("正在获取新文章id ...")
        url_new_article = 'https://www.liveinternet.ru/users/' + userData[
            'username'] + '/blog/'
        res = requestsW.get(url_new_article,
                            proxies=ip_proxy("en"),
                            headers=headers)
        if res == -1:
            return -1
        article_url = re.search(
            'https://www.liveinternet.ru/users/' +
            userData['username'].lower() + '/post(.*?)/', res.text)
        if not article_url:
            ('获取新发布文章url失败。。。')
            return 0
        try:
            new_article_url = article_url.group()
            sql = "INSERT INTO liveinternet_ru_article(url, keyword, user_id) VALUES('" + new_article_url + "', '" + article[
                0] + "', '" + str(userData["id"]) + "');"
            last_row_id = MysqlHandler().insert(sql)
            g_var.logger.info(last_row_id)
            if last_row_id != -1:
                g_var.logger.info('文章成功!' + userData['username'])
                return 'ok'
            else:
                g_var.ERR_CODE = 2004
                g_var.ERR_MSG = "数据库插入用户注册数据失败..."
                g_var.logger.error("数据库插入用户注册数据失败...")
                return 0
        except Exception as e:
            g_var.logger.info(e)
            g_var.ERR_CODE = 2004
            g_var.ERR_MSG = "数据库插入用户注册数据异常..."
            g_var.logger.error("数据库插入用户注册数据异常...")
            return 0