Beispiel #1
0
 def index_page(self, response):
     cookie = response.cookies
     sf = re.compile(r'value="(.\d*?)"/>').findall(response.text)[0]
     print('sf等于{}'.format(sf))
     url1 = 'http://credit.customs.gov.cn/ccppCopAction/createImage.action'
     username = '******'
     password = '******'
     appid = '4934'
     appkey = 'b7132447f5d2b263a61cd4252fd01d6a'
     resp1 = requests.get(url1, headers=self.headers, cookies=cookie)
     yundama = YDMHttp(username, password, appid, appkey)
     cid, vcode = yundama.decode_mem(resp1.content, '5006', 10)
     print('vcode:{}'.format(vcode))
     image = Image.open(io.BytesIO(resp1.content))
     #image.show()
     #post链接
     url2 = 'http://credit.customs.gov.cn/ccppCopAction/queryCopIn.action'
     #企业名,轮询,先用佛山市顺德区蓝基恩塑料有限公司代替
     data = 'copName=%E5%BF%AB%E9%92%B1%E6%94%AF%E4%BB%98%E6%B8%85%E7%AE%97%E4%BF%A1%E6%81%AF%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&sf={}&x=46&y=20&randomCode={}'.format(
         sf, vcode)
     html2 = requests.post(url2,
                           data=data,
                           headers=self.headers,
                           cookies=cookie).text
     print(len(html2))
Beispiel #2
0
 def __init__(self):
     self.url = 'http://readfree.me/accounts/login/?next=/'
     self.headers = {
         "Accept":
         "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
         "Accept-Encoding":
         "gzip, deflate",
         "Accept-Language":
         "zh-CN,zh;q=0.9,en-GB;q=0.8,en;q=0.7,ja;q=0.6",
         "Cache-Control":
         "max-age=0",
         "Connection":
         "keep-alive",
         "Host":
         "readfree.me",
         "Upgrade-Insecure-Requests":
         "1",
         "User-Agent":
         "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
     }
     self.s = requests.Session()
     self.yundama = YDMHttp()
     self.verify_code_url = ''
     self.verify_code_id = ''
     self.captcha_id = ''
     self.result = ''
Beispiel #3
0
    def __init__(self, browser):
        super(yanzhengma, self).__init__()
        # self.arg = arg
        self.browser = browser

        # 用户名
        username = '******'
        # 密码
        password = '******'
        # 软件ID,开发者分成必要参数。登录开发者后台【我的软件】获得!
        appid = 3035
        # 软件密钥,开发者分成必要参数。登录开发者后台【我的软件】获得!
        appkey = '0856355e1dd686e7819093bcd2843176'
        # 图片文件
        # filename	= 'getimage.jpg'
        # 验证码类型,# 例:1004表示4位字母数字,不同类型收费不同。请准确填写,否则影响识别率。在此查询所有类型 http://www.yundama.com/price.html
        # codetype	= 1004
        self.codetype = 5000
        # 超时时间,秒
        self.timeout = 60

        # 初始化
        self.yundama = YDMHttp(username, password, appid, appkey)

        # 登陆云打码
        uid = self.yundama.login()
        print 'uid: %s' % uid
        # 查询余额
        balance = self.yundama.balance()
        print 'balance: %s' % balance
Beispiel #4
0
class yanzhengma(object):
    """docstring for yanzhengma"""
    def __init__(self, browser):
        super(yanzhengma, self).__init__()
        # self.arg = arg
        self.browser = browser

        # 用户名
        username = '******'
        # 密码
        password = '******'
        # 软件ID,开发者分成必要参数。登录开发者后台【我的软件】获得!
        appid = 3035
        # 软件密钥,开发者分成必要参数。登录开发者后台【我的软件】获得!
        appkey = '0856355e1dd686e7819093bcd2843176'
        # 图片文件
        # filename	= 'getimage.jpg'
        # 验证码类型,# 例:1004表示4位字母数字,不同类型收费不同。请准确填写,否则影响识别率。在此查询所有类型 http://www.yundama.com/price.html
        # codetype	= 1004
        self.codetype = 5000
        # 超时时间,秒
        self.timeout = 60

        # 初始化
        self.yundama = YDMHttp(username, password, appid, appkey)

        # 登陆云打码
        uid = self.yundama.login()
        print 'uid: %s' % uid
        # 查询余额
        balance = self.yundama.balance()
        print 'balance: %s' % balance

    def recognise(self, imgfilename):

        # 开始识别,图片路径,验证码类型ID,超时时间(秒),识别结果
        cid, result = self.yundama.decode(imgfilename, self.codetype,
                                          self.timeout)
        print 'cid: %s, result: %s' % (cid, result)
        result = str(result)
        # print result
        result = result.replace('c_char_p', '')
        result = result.replace('(', '')
        result = result.replace(')', '')
        result = result.replace('\'', '')

        img_to_text = result

        #得到的是原始对象,使用原始的send_keys方法发送消息
        self.browser.getelementbycss('#ccode').send_keys(img_to_text.decode())
        time.sleep(0.3)
        self.browser.getelementbycss('#Button1').send_keys(Keys.ENTER)
        time.sleep(0.3)
Beispiel #5
0
    def index_page(self, response):

        cookie = response.cookies
        sf = re.compile(r'value="(.\d*?)"/>').findall(response.text)[0]
        print('sf等于{}'.format(sf))
        url1 = 'http://credit.customs.gov.cn/ccppCopAction/createImage.action'
        username = '******'
        password = '******'
        appid = '4934'
        appkey = 'b7132447f5d2b263a61cd4252fd01d6a'
        resp1 = requests.get(url1, headers=self.headers1, cookies=cookie)
        yundama = YDMHttp(username, password, appid, appkey)
        cid, vcode = yundama.decode_mem(resp1.content, '5006', 10)
        print('vcode:{}'.format(vcode))
        image = Image.open(io.BytesIO(resp1.content))
        image.show()
        # post链接
        url2 = 'http://credit.customs.gov.cn/ccppCopAction/queryCopIn.action'
        # 企业名,轮询,先用佛山市顺德区蓝基恩塑料有限公司代替
        key_word = ['佛山市顺德区蓝基恩塑料有限公司', '快钱支付清算信息有限公司', '中国银联股份有限公司']
        for k in range(len(key_word)):
            key = urllib.parse.quote(key_word[k])
            data = 'copName={}&sf={}&x=46&y=20&randomCode={}'.format(
                key, sf, vcode)
            html2 = requests.post(url2,
                                  data=data,
                                  headers=self.headers2,
                                  cookies=cookie).text
            # print(html2)
            detail = re.compile("getDetail(.*?);", re.S).findall(html2)
            for i in detail:
                if len(detail) > 20:
                    print("你检索的信息超过20条,请精确您的查询条件")
                    break
                i = eval(i)
                seqNo = i[0]
                saicSysNo = i[1]
                data2 = {'seqNo': i[0], 'saicSysNo': i[1]}
                print(data2)
                self.crawl(
                    'http://credit.customs.gov.cn/ccppCopAction/getDetail.action',
                    headers=self.headers2,
                    cookies=cookie,
                    data=data2,
                    callback=self.detail_page)
                print(k)
Beispiel #6
0
userInput = inputs[0]
passwordInput = inputs[1]
captchaInput = inputs[2]
onceInput = inputs[3]

userName = userInput.get('name')
passwordName = passwordInput.get('name')
captchaName = captchaInput.get('name')
onceValue = onceInput.get('value')

data = {
    userName: '******',
    passwordName: 'abcabc',
    "once": onceValue,
    'next': '/'
}

captcha_url = "https://www.v2ex.com/_captcha?once="+onceValue
imgResp = session.get(captcha_url,headers=headers)
with open("captcha.png",'wb') as fp:
    fp.write(imgResp.content)

ydm = YDMHttp("zhiliao","abcabc")
_,result = ydm.recognize_captcha('captcha.png','3000')
print(result)





Beispiel #7
0
from yundama import YDMHttp

ydm = YDMHttp(username='******', password='******')
uid = ydm.login()
if not uid:
    print("登录失败!")

balance = ydm.balance()
if balance < 10:
    print("余额不足!")

_, result = ydm.decode(filename='image.jpg', codetype="3004")
print(result)
Beispiel #8
0
data = {
    userName: '******',
    passwordName: 'abcabc',
    "once": onceValue,
    'next': '/'
}

while True:
    captcha_url = "https://www.v2ex.com/_captcha?once=" + onceValue
    imgResp = session.get(captcha_url, headers=headers)
    # 使用urlretrieve无法指定headers,导致不能下载
    with open("captcha.png", 'wb') as fp:
        fp.write(imgResp.content)

    # captchaValue = input("请输入验证码:")
    ydm = YDMHttp(username="******", password='******')
    _, captchaValue = ydm.recognize_captcha("captcha.png", "3007")

    data[captchaName] = captchaValue

    loginResp = session.post(login_url, headers=headers, data=data)
    if loginResp.status_code == 302:
        break

settingsResp = session.get(settings_url, headers=headers)
print(settingsResp.text)

# 1. 云打码背后是人手工识别的,有可能识别失败,所以需要做多次的登录,直到登录成功。
# 2. v2ex一天之内只能登录10次(有待确定),如果超过了个这个次数,那么想再登录就只能更换ip地址或者等到24小时以后。
Beispiel #9
0
class ReadFree(object):
    def __init__(self):
        self.url = 'http://readfree.me/accounts/login/?next=/'
        self.headers = {
            "Accept":
            "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
            "Accept-Encoding":
            "gzip, deflate",
            "Accept-Language":
            "zh-CN,zh;q=0.9,en-GB;q=0.8,en;q=0.7,ja;q=0.6",
            "Cache-Control":
            "max-age=0",
            "Connection":
            "keep-alive",
            "Host":
            "readfree.me",
            "Upgrade-Insecure-Requests":
            "1",
            "User-Agent":
            "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
        }
        self.s = requests.Session()
        self.yundama = YDMHttp()
        self.verify_code_url = ''
        self.verify_code_id = ''
        self.captcha_id = ''
        self.result = ''

    def to_douban(self):
        t = self.s.get(self.url, headers=self.headers)
        selector = etree.HTML(t.text)
        douban_url = urljoin(self.url,
                             selector.xpath(".//*/a[text()='豆瓣登录']/@href")[0])
        douban_response = self.s.get(douban_url)
        douban_selector = etree.HTML(douban_response.text)

        self.verify_code_url = douban_selector.xpath(
            ".//*/img[@id='captcha_image']/@src")
        self.verify_code_id = douban_selector.xpath(
            ".//*/input[@name='captcha-id']/@value")
        if self.verify_code_url and self.verify_code_id:
            verify_code_res = requests.get(self.verify_code_url[0])
            self.captcha_id = self.verify_code_id[0]
            with open('douban.png', 'wb') as f:
                f.write(verify_code_res.content)
        try:
            self.yundama.login()
            self.result = self.yundama.decode('douban.png')
        except Exception as e:
            logger.error('云打码出错, 不能登录或者识别验证码失败', exc_info=True)
        douban_form_state = douban_selector.xpath(
            "substring-before(substring-after(.//*/form[@id='refuse_form']/@action, '?state='), '&')"
        )
        if douban_form_state:
            douban_state = douban_form_state
            to_readfree_url = 'https://www.douban.com/service/auth2/auth?state=' + douban_state + '&redirect_uri=http://readfree.me/auth/douban/login/callback/&scope=&client_id=018746ee51b1a6ad0495d4caf514f407&response_type=code'
        else:
            to_readfree_url = None
        return to_readfree_url

    def to_readfree(self):
        to_readfree_url = self.to_douban()
        if self.verify_code_id:
            data = {
                "user_alias": "*****",
                "user_passwd": "***",
                "captcha-id": self.captcha_id,
                "captcha-solution": self.result[1],
                "confirm": "授权"
            }
        else:
            data = {
                "user_alias": "****",
                "user_passwd": "****",
                "confirm": "授权"
            }

        if to_readfree_url:
            response = self.s.post(to_readfree_url, data=data)
            if '亚马逊' in response.url:
                response = self.s.get('http://readfree.me/')
            elif 'readfree' in response.url:
                logger.info('没有跳转到亚马逊')
            readfree_selector = etree.HTML(response.text)
            user_url = readfree_selector.xpath(".//*/a[text()='个人中心']/@href")
            return user_url

    def get_score(self):
        user_url = self.to_readfree()
        if user_url:
            url = urljoin('http://readfree.me', user_url[0])
            user_page_res = self.s.get(url, headers=self.headers)
            score_selector = etree.HTML(user_page_res.text)
            score = score_selector.xpath(
                "substring-before(substring-after(.//*/div[@class='clearfix']/following-sibling::p[1]/text(), '剩余额度:'), ',')"
            )
            return str(score).strip() if score else None

    def mail_run(self):
        email = EMAIL()
        score = self.get_score()
        balance = self.yundama.balance()
        time = datetime.now() + timedelta(days=-1)
        if balance < 10 and score:
            contents = '{0} 云打码余额为: {1}, 余额已经不足请尽快充值。'.format(
                time.strftime('%Y-%m-%d %H:%M'), balance)
        elif balance <= 0 and score:
            contents = '{0} 云打码余额为: {1}, 余额已经不足,无法用于下次验证。\n现在积分为{2}。'.format(
                time.strftime('%Y-%m-%d %H:%M'), balance, score)
        elif balance >= 10 and score:
            contents = '{0} 云打码余额为: {1}, 余额较为充裕。\n现在ReadFree额度为{2}。'.format(
                time.strftime('%Y-%m-%d %H:%M'), balance, score)
        else:
            contents = '{0} 没有获取到ReadFree额度。'.format(
                time.strftime('%Y-%m-%d %H:%M'))
        try:
            email.send(contents, config['email_subject1'])
        except Exception as e:
            logger.error('邮件模块出现问题,不能正常发送邮件', exc_info=True)
        else:
            logger.info('邮件发送成功\n')
Beispiel #10
0
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'Cookie': 'aisino-wsbs-session=de016770-5a45-406e-a5c5-53c74f6503a2',
    'Host': 'etax.ah-n-tax.gov.cn',
    'Upgrade-Insecure-Requests': '1',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.79 Safari/537.36',
}

#主页url
url = 'http://etax.ah-n-tax.gov.cn/nsr/wzdk/checkybnsrrd'

#验证码url
url2 = 'http://etax.ah-n-tax.gov.cn/nsr/validate?randomNum=654.2100508709448'
imag = requests.get(url2,headers=headers).content

yundama = YDMHttp(username, password, appid, appkey)
cid, vcode = yundama.decode_mem(imag, '5006', 10)
print(vcode)
image = Image.open(io.BytesIO(imag))
image.show()

#查询post

url3 = 'http://etax.ah-n-tax.gov.cn/nsr/wzdk/checkybnsrrd'
data = {
    'nsrsbh':'9134030078306486X3', #信用代码
    'vcode':vcode,#验证码
}
result =  requests.post(url3,headers=headers,data=data).text
print(result)
Beispiel #11
0
ydmUsername = '******'  # 用户名
ydmPassword = '******'  # 密码
appid = 1  # 开发者相关 功能使用和用户无关
appkey = '22cc5376925e9387a23cf797cb9ba745'  # 开发者相关 功能使用和用户无关
filename = 'cache.png'  # 验证码截图
# 验证码类型,# 例:1004表示4位字母数字,不同类型收费不同。请准确填写,否则影响识别率。在此查询所有类型 http://www.yundama.com/price.html
codetype = 1004
# 超时时间,秒
timeout = 60

# 检查
if (ydmUsername == ''):
    print('请设置好相关参数再测试')
else:
    # 初始化
    yundama = YDMHttp(ydmUsername, ydmPassword, appid, appkey)
    # 登陆云打码
    uid = yundama.login()
    print('云打码登录成功 uid: %s' % uid)
    # # 查询余额
    # balance = yundama.balance()
    # print('balance: %s' % balance)

    # # 开始识别,图片路径,验证码类型ID,超时时间(秒),识别结果
    # cid, result = yundama.decode(filename, codetype, timeout)
    # print('cid: %s, result: %s' % (cid, result))

### yundama -------------------------------------


def get_snap(driver):  # 对目标网页进行截屏。这里截的是全屏
Beispiel #12
0
base_url = 'http://credit.customs.gov.cn/'
resp = requests.get(base_url, headers=headers1)
cookie = resp.cookies.get_dict()
print(cookie)
sf = re.findall(r'type="hidden" value="(.*?)"', resp.text)[0]
print(sf)

url1 = 'http://credit.customs.gov.cn/ccppCopAction/createImage.action'

resp1 = requests.get(url1, headers=headers1, cookies=cookie)

# dma =DamaAPI(vctype='cpws_num')
# vcode = dma.yundamaByCode(resp1.content,codetype='5006')

yundama = YDMHttp(username, password, appid, appkey)
cid, vcode = yundama.decode_mem(resp1.content, '5006', 10)
print(vcode)
image = Image.open(io.BytesIO(resp1.content))
image.show()

headers2 = {
    'Accept':
    'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
    'Accept-Encoding':
    'gzip, deflate',
    'Accept-Language':
    'zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
    'Content-Type':
    'application/x-www-form-urlencoded',
    'Origin':