ICEBREAKER101010 Posted March 22, 2019 Report Posted March 22, 2019 Salutare tuturor. As avea si eu nevoie de ceva ajutor in legatura cu un script facut un python. Scriptul respectiv se logheaza pe un site anume si creeaza un fisier denumit cookies. Ideea e ca nu prea reusesc sa il fac sa functioneze : from __future__ import unicode_literals from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait import sys, time import youtube_dl import os username = sys.argv[1] pwd = sys.argv[2] url = sys.argv[3] cookie_file = 'cookies.txt' print("Don't touch this one") # remove cookie file if it exists if os.path.exists( cookie_file 😞 os.remove( cookie_file ) # recreate file and open in append mode f = open( cookie_file, 'a+') # cookie function def get_cookies(): expiry = 0 for i in driver.get_cookies(): if not i.get('expiry'): expiry = 0 else: expiry = i.get('expiry') cookie = '{}\t{}\t{}\t{}\t{}\t{}\t{}\n'.format( i['domain'], str( i['httpOnly'] ).upper(), i['path'], str( i['secure'] ).upper(), expiry, i['name'], i['value'] ) f.write( cookie ) # chrome options options = webdriver.ChromeOptions() options.add_argument("--headless") options.add_argument("--window-size=1280,720") # initiate browser driver = webdriver.Chrome( options=options ) # navigate to ine driver.get("http://members.ine.com/") driver.implicitly_wait(10) # click login link link = find_element_by_class_name("form-group") link.click() # get cookies from members.ine.com print("Getting cookies from members.ine.com/auth/login") get_cookies() # wait until login screen appears print("Sleeping for 5 seconds..") time.sleep(5) print("Attempting to login..") user = driver.find_element_by_name('email') user.send_keys( username ) password = driver.find_element_by_name('password') password.send_keys( pwd ) password.send_keys(Keys.RETURN) Multumesc! Quote
u0m3 Posted March 24, 2019 Report Posted March 24, 2019 Vezi ca este un buton special pentru inserat cod intr-un post Ce nu reusesti sa faci sa mearga? Pentru salvat/incarcat cookies incearca https://stackoverflow.com/questions/15058462/how-to-save-and-load-cookies-using-python-selenium-webdriver 1 Quote
ICEBREAKER101010 Posted March 25, 2019 Author Report Posted March 25, 2019 (edited) 19 hours ago, u0m3 said: Vezi ca este un buton special pentru inserat cod intr-un post Ce nu reusesti sa faci sa mearga? Pentru salvat/incarcat cookies incearca https://stackoverflow.com/questions/15058462/how-to-save-and-load-cookies-using-python-selenium-webdriver Salut. Am reusit sa il fac sa functioneze.Se logheaza cum trebuie, salveaza cookies si le transforma in cookies pentru curl(de care are nevoie youtube-dl) dar nu merge sa downloadez videourile de pe cloudacademy. Probabil mai trebuie ceva cod pentru a extrage linkurile cu videouri din pagina unde se afla un anumit curs.Asa de downloadat, merge cu IDM dar vreau ceva automat. Ma doare mana sa dau atatea clickuri Multumesc! Edited March 25, 2019 by ICEBREAKER101010 Quote