예제 #1
0
파일: login.py 프로젝트: xlu127/zhihuSpider
 def captcha(self):
     '''
     可改写验证码的获取方式,此处使用打码平台识别验证码
     :return:
     '''
     api = FateadmApi(app_id="", app_key="", pd_id="", pd_key="")
     captcha = api.PredictFromFile("20400", "captcha.png").pred_rsp.value
     return captcha
def get_code_value(file=""):
    pd_id = "125194"
    pd_key = "YJbdXa7Fxpfr+4roIOFL3gY3uVwmuwrx"
    app_id = "325194"
    app_key = "3defiZZPh4yCyuEXvcuxJOfL8kq2f7Pp"
    api = FateadmApi(app_id, app_key, pd_id, pd_key)
    # 通过文件形式识别:
    pred_type = "30400"
    # 直接返回识别结果
    rsp = api.PredictExtend(pred_type, file)

    return rsp
예제 #3
0
def cookie_init():
	retries = 1
	while retries < 3:
		cookie = {}
		headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/65.0.3325.181 Safari/537.36'}
		chrome_options = webdriver.ChromeOptions()
		chrome_options.add_argument('--headless')
		chrome_options.add_argument('--disable-gpu')
		chrome_options.add_argument('--no-sandbox')
		chrome_options.add_argument('--disable-dev-shm-usage')
		client = webdriver.Chrome(options=chrome_options)
		client.get("https://weixin.sogou.com/antispider/?from=%2fweixin%3Ftype%3d2%26query%3d360CERT")
		path = './1.png'
		imgpath = './yzm.png'
		client.get_screenshot_as_file(path)
		im = Image.open(path)
		box = (705, 598, 900, 680)  # 设置要裁剪的区
		region = im.crop(box)
		region.save(imgpath)
		capt = client.find_element_by_xpath('//*[@id="seccodeInput"]')
		test = FateadmApi('','','','')  #打码平台接口
		code = test.PredictFromFile('30600','./yzm.png')  #打码平台识别
		#code = '123456'
		print(code)
		capt.send_keys(code)
		time.sleep(1)
		client.find_element_by_xpath('//*[@id="submit"]').click()
		time.sleep(2)
		#print(new_html)
		for item in client.get_cookies():
		    cookie[item["name"]] = item["value"]
		try:
			print(cookie['SNUID'])
		except Exception:
			print ("解锁失败。重试次数:{0:d}".format(3-retries))
			retries += 1
			continue
		time.sleep(5)
		return cookie['SNUID']
예제 #4
0
#         params.update(self.base_params)
#         try:
#             r = requests.post('http://api.ruokuai.com/reporterror.json', data=params, headers=self.headers)
#             return r.json()
#         except exceptions as e:
#             print e
# rc = RClient(rk_username, rk_password, '121093', 'c746b4d86af24b27b18bd3c0a92a6a79')

pd_id = "112729"
pd_key = "HsfKii2YwtjeyMNlmqMaQQ9Le1XHMzYn"
app_id = "312729"
app_key = "05+HjIfGKIRkuuFhqaoQR21SDx3qSa6c"
# 具体类型可以查看官方网站的价格页选择具体的类型,不清楚类型的,可以咨询客服
pred_type = "20400"
# 初始化api接口
api = FateadmApi(app_id, app_key, pd_id, pd_key)

def ff_dama(image_data):
    rep = api.Predict(pred_type,image_data)
    return rep

def verifyCodeImg(imageurl):
    headers = {
        "User-Agent": driver.execute_script("return navigator.userAgent;")
    }
    s = requests.session()
    s.headers.update(headers)
    for cookie in driver.get_cookies():
        c = {cookie['name']: cookie['value']}
        s.cookies.update(c)
    r = s.get(imageurl, allow_redirects=True)
예제 #5
0
import json
from datetime import datetime, timedelta
from bot import Bot


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'

options = Options()
options.add_argument('--headless')
options.add_argument(f'--user-agent="{USER_AGENT}"')

driver = webdriver.Firefox(options=options)
wait = WebDriverWait(driver, 5, 0.5)

config = json.load(open('config.json'))
fateadm_api = FateadmApi(app_id=None, app_key=None, pd_id=config['fateadm_id'], pd_key=config['fateadm_key'])
bot = Bot(config['telegram_token'])

captcha_cache = {}
refunded_captcha = {}

def recognize_captcha(image_url):
    # search cache
    if image_url in captcha_cache:
        print('Captcha in cache')
        return captcha_cache[image_url]
    
    print('Using fateadm to recognize captcha')
    res = requests.get(image_url, headers={"User-Agent": USER_AGENT})
    captcha_result = fateadm_api.Predict("20400", res.content)
    if captcha_result.ret_code == 0: