Access Lovoo API using Python Access Lovoo API using Python python-3.x python-3.x

Access Lovoo API using Python


An alternative approach would be the use of selenium for login and further using the session with requests.

E.g.

def login(user, pw):    chrome_options = Options()    chrome_options.add_experimental_option("detach", True)    driver = webdriver.Chrome(options=chrome_options)    driver.get("https://www.lovoo.com/login_check")    user_agent = driver.execute_script("return navigator.userAgent;")    iframe = driver.find_element(By.ID,"gdpr-consent-notice")    driver.switch_to.frame(iframe)    privacybutton = WebDriverWait(driver, 10).until(        EC.presence_of_element_located((By.XPATH,"//b[contains(text(),'Accept All')]"))    )    privacybutton.click()    driver.switch_to.default_content()    loginbutton = WebDriverWait(driver, 4).until(        EC.presence_of_element_located((By.XPATH, "//button[contains(text(),'Log in')]"))    )    loginbutton.click()    loginbutton2=WebDriverWait(driver, 4).until(        EC.presence_of_element_located((By.XPATH, "//button[contains(@data-automation-id,'login-submit-button')]"))    )    driver.find_element(By.XPATH, '//input[@name="authEmail"]').send_keys(user)    driver.find_element(By.XPATH, '//input[@name="authPassword"]').send_keys(pw)    webdriver.ActionChains(driver).move_to_element(loginbutton2).click(loginbutton2).perform()    element = WebDriverWait(driver, 10).until(        EC.presence_of_element_located((By.ID, "topmenu"))    )    return user_agent, driver.get_cookies()
(lat,lon)=(0.0,0.0)with requests.Session() as session:    user_agent, cookies = login(user, pw)    session.cookies.update({c['name']: c['value'] for c in cookies})    session.headers.update({'User-Agent': user_agent})    session.get(f'https://www.lovoo.com/api_web.php/users?ageFrom=0&ageTo=2&latitude={lat}&longitude={lon}')