Antony's Blog

Free Udemy courses, Next Level

May 31, 2020

Free Udemy courses, Next Level

In my last post I told you about how I managed to pull out udemy course URLs, but still clicking from a text file can be pretty tough if it contains ~500 links per day, then What to do 🤔
👉 HTML and mouse automation

Get ready for the Magic

You may be wondering why didn’t I use web-drivers and selenium for automation, trust me I did but the results where absolutely worthless, I spend hours on selenium and google web-driver but the links always opens in a sand box hence, udemy detects it and logouts you and its protected by a capta Here is where the good old mouse automation helps us.but how to make links click able 🙋
👉 make a html out of it.

file = open("/home/antony/Code/Telegram/urls.html", "w") 
    file.write("<html><head></head><body>")
    for url in udemy_url:
        if(not(url in lines)):
            try:
                file.write(f'<a href="{url}"> {url} </a> <br>') 
            except:
                pass
    file.write("</body></html>")
    file.close() 

this is the exact code I used.👍

after that it all “pyautogui” these are packages required to start

import pyautogui 
import os
import time

get all important screen points by using:

print(pyautogui.size())
print(pyautogui.position())

then point the mouse to the first URL increment step size (step = 17), then the process gets tricky when the last URL in the screen is reached hence we use the scroll function to scroll to the next block of URLs.

for _ in range(15):
        pyautogui.click(x_scroll, y_scroll)

after you click a URL using pyautogui.click(x_inital, y_inital) then find the enroll button in the screen od udemy hence we can do something like this pyautogui.click(x_enroll, y_enroll) don’t forget to time.sleep(10) as it takes time to load the website or a click will be wasted.

there you have it, all udemy URL in HTML and auto mouse clicking.

If you want to go a little further incorporate a mouse click task using python threading so that you don’t need to change screen timeout and don’t need to type in passwords on timeout.

x = threading.Thread(target=fake_mouse, args=(True,))
x.start()