Пример #1
0
import binascii
from urllib.parse import quote_plus
import requests
from config import conf
from headers import headers
from db.redis_db import Cookies
from utils import code_verification
from page_parse.basic import is_403
from logger.log import crawler, other
from db.login_info import freeze_account

# todo 这里如果是多个账号并发登录,那么验证码可能会被覆盖思考一种对应的方式
verify_code_path = './pincode.png'
index_url = "http://weibo.com/login.php"
yundama_username = conf.get_code_username()
yundama_password = conf.get_code_password()


def get_pincode_url(pcid):
    size = 0
    url = "http://login.sina.com.cn/cgi/pin.php"
    pincode_url = '{}?r={}&s={}&p={}'.format(
        url, math.floor(random.random() * 100000000), size, pcid)
    return pincode_url


def get_img(url):
    resp = requests.get(url, headers=headers, stream=True)
    with open(verify_code_path, 'wb') as f:
        for chunk in resp.iter_content(1000):
            f.write(chunk)
Пример #2
0
import binascii
from urllib.parse import quote_plus
import requests
from config import conf
from headers import headers
from db.redis_db import Cookies
from utils import code_verification
from page_parse.basic import is_403
from logger.log import crawler, other
from db.login_info import freeze_account


verify_code_path = './{}{}.png'
index_url = "http://weibo.com/login.php"
yundama_username = conf.get_code_username()
yundama_password = conf.get_code_password()


def get_pincode_url(pcid):
    size = 0
    url = "http://login.sina.com.cn/cgi/pin.php"
    pincode_url = '{}?r={}&s={}&p={}'.format(url, math.floor(random.random() * 100000000), size, pcid)
    return pincode_url


def get_img(url, name, retry_count):
    """
    :param url: url for verification code
    :param name: login account
    :param retry_count: retry number for getting verfication code
    :return: