-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathChrome_udemy.py
78 lines (64 loc) · 2.77 KB
/
Chrome_udemy.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from selenium import webdriver
from getpass import getpass
from selenium.webdriver.common import keys
import time
import sys
import re
from colorama import Fore
print(Fore.GREEN + '''
_ _ _ _ _
| | | | __| | ___ _ __ ___ _ _ / \ _ _| |_ ___
| | | |/ _` |/ _ \ '_ ` _ \| | | | / _ \| | | | __/ _ \
| |_| | (_| | __/ | | | | | |_| | / ___ \ |_| | || (_) |
\___/ \__,_|\___|_| |_| |_|\__, | /_/ \_\__,_|\__\___/
|___/
_____ _ _
| ____|_ __ _ __ ___ | | | ___ _ __
| _| | '_ \| '__/ _ \| | |/ _ \ '__|
| |___| | | | | | (_) | | | __/ |
|_____|_| |_|_| \___/|_|_|\___|_|
Github : https://github.com/the-avengersz\n
TG : https://t.me/the_avengersz
''')
emailid=input(Fore.RED+ 'Enter Email Address: ')
passwordd=getpass()
browser = webdriver.Chrome()
def login():
browser.get('https://www.udemy.com/join/login-popup/')
time.sleep(5)
mail=browser.find_elements_by_xpath('//*[@id="email--1"]')
mail[0].send_keys(emailid)
passs=browser.find_elements_by_css_selector('#id_password')
passs[0].send_keys(passwordd)
browser.find_element_by_xpath('//*[@id="submit-id-submit"]').click()
def auth():
browser.get('https://www.udemy.com/')
time.sleep(10)
try:
browser.find_element_by_xpath('/html/body/div[2]/div[3]/div[1]/nav/ul/li[2]/div/a')
except:
print(Fore.RED + 'Invalid Email/Password Recheck and Rerun Once. ')
browser.quit()
sys. exit()
else:
print(Fore.GREEN + 'Login Sucess, Enrolling Now')
def Enrolled():
with open('courses.txt','r')as courses:
for line in courses:
if re.search("https://www.udemy.com/", line):
browser.get(line)
time.sleep(15)
try:
enroll=browser.find_element_by_xpath('/html/body/div[2]/div[3]/div[1]/div[3]/div/div/div/div[1]/div/div[1]/div[2]/div/div[1]/div/div[5]/div/button')
browser.execute_script("arguments[0].click();", enroll)
time.sleep(15)
enrollnow=browser.find_element_by_xpath('/html/body/div[1]/div[2]/div/div/div/div[2]/form/div[2]/div/div[4]/button')
browser.execute_script("arguments[0].click();", enrollnow)
print('Sucesfully Enrolled '+line)
except:
print(Fore.RED + "Course Not Free or Coupan expired. So Trying to enroll Next one from the list ")
else:
print(Fore.RED + "PLease Enter a valid URL. Trying to enroll Next one from the list.")
login()
auth()
Enrolled()