Last active
February 24, 2025 23:16
-
-
Save HunterXProgrammer/beb06a5387bee78ee321fbe3c724d95e to your computer and use it in GitHub Desktop.
Revisions
-
HunterXProgrammer revised this gist
Jul 9, 2023 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ >https://www.reddit.com/r/tasker/comments/14e445n/comment/jozkd3t/ > >>yes | pkg upgrade -y >> >>pkg install -y tur-repo x11-repo python-pip >> @@ -37,7 +37,7 @@ I'll give here a python script showing how to - > >termux-setup-storage > > yes | pkg upgrade -y > > pkg install -y tur-repo x11-repo python-pip > @@ -137,7 +137,7 @@ I've also added a lot of comments for you to understand what each line does. > > termux-setup-storage > > yes | pkg upgrade -y > > pkg install -y tur-repo x11-repo python-pip > -
HunterXProgrammer revised this gist
Jun 23, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -116,7 +116,7 @@ Press enter, and then copy paste this - finally: # Exit Headless Chromium driver.close() After that, press **CRTL + X + Y + ENTER** to save and exit. @@ -215,7 +215,7 @@ Press enter, and then copy paste this - finally: # Exit Headless Firefox driver.close() After that, press **CRTL + X + Y + ENTER** to save and exit. -
HunterXProgrammer revised this gist
Jun 22, 2023 . No changes.There are no files selected for viewing
-
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,7 +66,7 @@ Press enter, and then copy paste this - options.add_argument("--incognito") options.add_argument("--hide-scrollbars") # Setting User-Agent to mobile to get pages as if viewed in mobile options.add_argument('--user-agent="Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36"') try: @@ -165,7 +165,7 @@ Press enter, and then copy paste this - options.add_argument("--headless") options.add_argument("--private-window") # Setting User-Agent to mobile to get pages as if viewed in mobile options.set_preference("general.useragent.override", "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36") try: -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -47,7 +47,7 @@ I'll give here a python script showing how to - Now to write and save the python script, do - nano reddit_screenshot_chromium.py Press enter, and then copy paste this - @@ -122,7 +122,7 @@ After that, press **CRTL + X + Y + ENTER** to save and exit. Now just append the Reddit username and password when you run the python script, like this - `python reddit_screenshot_chromium.py "some_username" "the_password"` I've made it so that it prints each step so that you'll know the progress of the script. -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -82,7 +82,7 @@ Press enter, and then copy paste this - print(" Loading url https://www.reddit.com/login\n") driver.get("https://www.reddit.com/login") # Reddit uses iframe for login box, so switching to it. No needed for most other sites, this is for demonstration driver.switch_to.frame(WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.XPATH, "//*[@id='container']/div/div[1]/div[1]/iframe")))) # Selecting input field, and entering first argument as Username @@ -181,7 +181,7 @@ Press enter, and then copy paste this - print(" Loading url https://www.reddit.com/login\n") driver.get("https://www.reddit.com/login") # Reddit uses iframe for login box, so switching to it. No needed for most other sites, this is for demonstration driver.switch_to.frame(WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.XPATH, "//*[@id='container']/div/div[1]/div[1]/iframe")))) # Selecting input field, and entering first argument as Username -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -163,7 +163,6 @@ Press enter, and then copy paste this - options = Options() options.add_argument("--headless") options.add_argument("--private-window") # Setting User-Agent to mobile to get pages as if in viewed mobile -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -163,6 +163,7 @@ Press enter, and then copy paste this - options = Options() options.add_argument("--headless") options.set_preference("dom.disable_scroll_bars", True) options.add_argument("--private-window") # Setting User-Agent to mobile to get pages as if in viewed mobile -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -115,7 +115,7 @@ Press enter, and then copy paste this - print(" Screenshot saved to Download/screenshot.jpg\n") finally: # Exit Headless Chromium driver.quit() After that, press **CRTL + X + Y + ENTER** to save and exit. -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -64,6 +64,7 @@ Press enter, and then copy paste this - options.add_argument("--headless=new") options.add_argument("--incognito") options.add_argument("--hide-scrollbars") # Setting User-Agent to mobile to get pages as if in viewed mobile options.add_argument('--user-agent="Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36"') -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -228,4 +228,4 @@ All done. Selenium is blazing fast when it comes to huge amounts of navigating, element searching, clicking, and so on. You'll certainly like it even more if you're a power user :-) -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -127,7 +127,7 @@ I've made it so that it prints each step so that you'll know the progress of the I've also added a lot of comments for you to understand what each line does. **You can also use Firefox, but I recommend using Chromium since I found it faster (by around 7s) for the same script, as well as having more know-hows.** -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ > >From what i get you can't just use Selenium with just Termux and Chromium on Android. If you have some knowledge how to do that i would love to hear! No worries, it's all about trying a little at first and slowly becoming used to it! I'll give here a python script showing how to - -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,17 +37,17 @@ I'll give here a python script showing how to - > >termux-setup-storage > > pkg upgrade -y > > pkg install -y tur-repo x11-repo python-pip > > pkg install -y chromium > > pip install selenium Now to write and save the python script, do - nano reddit_screenshot_chrome.py Press enter, and then copy paste this - @@ -134,19 +134,19 @@ I've also added a lot of comments for you to understand what each line does. ### **For Firefox** >**Setup once:-** > > termux-setup-storage > > pkg upgrade -y > > pkg install -y tur-repo x11-repo python-pip > > pkg install -y firefox geckodriver > > pip install selenium Now to write and save the python script, do - nano reddit_screenshot_firefox.py Press enter, and then copy paste this - -
HunterXProgrammer revised this gist
Jun 22, 2023 . 1 changed file with 2 additions and 162 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,27 +1,15 @@ >https://www.reddit.com/r/tasker/comments/14e445n/comment/jozkd3t/ > >>pkg upgrade -y >> >>pkg install -y tur-repo x11-repo python-pip >> >>pkg install -y chromium >> >>pip install selenium > >If you know how i would love to get some info about Selenium and Android. > >From what i get you can't just use Selenium with just Termux and Chromium on Android. If you have some knowledge how to do that i would love to hear! No worries, it's all about trying a little at first and slowing becoming used to it! @@ -45,27 +33,16 @@ I'll give here a python script showing how to - ### **For Chromium** >**Setup once:-** > >termux-setup-storage > >pkg upgrade -y > >pkg install -y tur-repo x11-repo python-pip > >pkg install -y chromium > >pip install selenium Now to write and save the python script, do - @@ -75,133 +52,69 @@ Now to write and save the python script, do - Press enter, and then copy paste this - #!/data/data/com.termux/files/usr/bin/python import sys from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC options = Options() options.add_argument("--headless=new") options.add_argument("--incognito") # Setting User-Agent to mobile to get pages as if in viewed mobile options.add_argument('--user-agent="Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36"') try: # Start Headless Chromium print("\n Launching Chromium (Headless mode)\n (No GUI = no resources wasted)\n") driver = webdriver.Chrome(options=options) # Setting browser size to more mobile-like dimensions print(" Setting browser size to more mobile-like dimensions\n") driver.set_window_size(driver.get_window_size()['width']/2, driver.get_window_size()['height']) # Loading url https://www.reddit.com/login print(" Loading url https://www.reddit.com/login\n") driver.get("https://www.reddit.com/login") # Reddit uses iframe for login box, so swithing to it. No needed for most other sites, this is for demonstration driver.switch_to.frame(WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.XPATH, "//*[@id='container']/div/div[1]/div[1]/iframe")))) # Selecting input field, and entering first argument as Username print(" Selecting Username field and entering Username\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input#loginUsername"))).send_keys(sys.argv[1]) # Selecting input field, and entering second argument as Password print(" Selecting Password field and entering Password\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input#loginPassword"))).send_keys(sys.argv[2]) # Clicking the Login button print(" Clicking the Login button\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.AnimatedForm__submitButton.m-full-width.m-modalUpdate"))).click() # Switching back from previous iframe to current window driver.switch_to.window(driver.window_handles[0]) # Reddit always gives annoying prompt telling us to try their app. This will click continue in browser option print(" Dismissing the Reddit prompt where they tell us to\n use their app\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.XPromoPopupRpl__actionButton"))).click() # Loading the "Comments you have received" section, which is visible only after successful login print(' Loading the "Comments you have received" section,\n which is visible only after successful login\n') driver.get("https://www.reddit.com/notification/comments") # Taking screenshot and saving it to /sdcard/Download/screenshot.png # Don't forget to give Termux storage access or else it won't be able to save print(" Taking screenshot and saving it to\n /sdcard/Download/screenshot.png\n") driver.save_screenshot("/sdcard/Download/screenshot.png") print(" Screenshot saved to Download/screenshot.jpg\n") finally: # Exit Headless Chrome driver.quit() After that, press **CRTL + X + Y + ENTER** to save and exit. @@ -219,27 +132,16 @@ I've also added a lot of comments for you to understand what each line does. ### **For Firefox** >**Setup once:-** > >termux-setup-storage > >pkg upgrade -y > >pkg install -y tur-repo x11-repo python-pip > >pkg install -y firefox geckodriver > >pip install selenium Now to write and save the python script, do - @@ -249,131 +151,69 @@ Now to write and save the python script, do - Press enter, and then copy paste this - #!/data/data/com.termux/files/usr/bin/python import sys from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.firefox.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC options = Options() options.add_argument("--headless") options.add_argument("--private-window") # Setting User-Agent to mobile to get pages as if in viewed mobile options.set_preference("general.useragent.override", "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36") try: # Start Headless Firefox print("\n Launching Firefox (Headless mode)\n (No GUI = no resources wasted)\n") driver = webdriver.Firefox(options=options) # Setting browser size to more mobile-like dimensions print(" Setting browser size to more mobile-like dimensions\n") driver.set_window_size(driver.get_window_size()['width']/2, driver.get_window_size()['height']) # Loading url https://www.reddit.com/login print(" Loading url https://www.reddit.com/login\n") driver.get("https://www.reddit.com/login") # Reddit uses iframe for login box, so swithing to it. No needed for most other sites, this is for demonstration driver.switch_to.frame(WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.XPATH, "//*[@id='container']/div/div[1]/div[1]/iframe")))) # Selecting input field, and entering first argument as Username print(" Selecting Username field and entering Username\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input#loginUsername"))).send_keys(sys.argv[1]) # Selecting input field, and entering second argument as Password print(" Selecting Password field and entering Password\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input#loginPassword"))).send_keys(sys.argv[2]) # Clicking the Login button print(" Clicking the Login button\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.AnimatedForm__submitButton.m-full-width.m-modalUpdate"))).click() # Switching back from previous iframe to current window driver.switch_to.window(driver.window_handles[0]) # Reddit always gives annoying prompt telling us to try their app. This will click continue in browser option print(" Dismissing the Reddit prompt where they tell us to\n use their app\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.XPromoPopupRpl__actionButton"))).click() # Loading the "Comments you have received" section, which is visible only after successful login print(' Loading the "Comments you have received" section,\n which is visible only after successful login\n') driver.get("https://www.reddit.com/notification/comments") # Taking screenshot and saving it to /sdcard/Download/screenshot.png # Don't forget to give Termux storage access or else it won't be able to save print(" Taking screenshot and saving it to\n /sdcard/Download/screenshot.png\n") driver.save_screenshot("/sdcard/Download/screenshot.png") print(" Screenshot saved to Download/screenshot.jpg\n") finally: # Exit Headless Firefox driver.quit() After that, press **CRTL + X + Y + ENTER** to save and exit. -
HunterXProgrammer created this gist
Jun 22, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,391 @@ >https://www.reddit.com/r/tasker/comments/14e445n/comment/jozkd3t/ > >>pkg upgrade -y >> >>pkg install -y tur-repo x11-repo python-pip >> >>pkg install -y chromium >> >>pip install selenium > >If you know how i would love to get some info about Selenium and Android. > >From what i get you can't just use Selenium with just Termux and Chromium on Android. If you have some knowledge how to do that i would love to hear! No worries, it's all about trying a little at first and slowing becoming used to it! I'll give here a python script showing how to - **1\)** Use selenium in Chromium or Firefox **2\)** Open Reddit login page **3\)** Make the layout like as if viewing in mobile **4\)** Enter Username and Password and click Login button **5\)** Dismiss the Reddit prompt that tells use to use their app **6\)** Load the "Comments you have received" setion, which is only visible after a successful login. **7\)** And take a screenshot and save it to `Download/screenshot.png` ### **For Chromium** >**Setup once:-** > >termux-setup-storage > >pkg upgrade -y > >pkg install -y tur-repo x11-repo python-pip > >pkg install -y chromium > >pip install selenium Now to write and save the python script, do - `nano reddit_screenshot_chrome.py` Press enter, and then copy paste this - #!/data/data/com.termux/files/usr/bin/python import sys from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.chrome.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC options = Options() options.add_argument("--headless=new") options.add_argument("--incognito") # Setting User-Agent to mobile to get pages as if in viewed mobile options.add_argument('--user-agent="Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36"') try: # Start Headless Chromium print("\n Launching Chromium (Headless mode)\n (No GUI = no resources wasted)\n") driver = webdriver.Chrome(options=options) # Setting browser size to more mobile-like dimensions print(" Setting browser size to more mobile-like dimensions\n") driver.set_window_size(driver.get_window_size()['width']/2, driver.get_window_size()['height']) # Loading url https://www.reddit.com/login print(" Loading url https://www.reddit.com/login\n") driver.get("https://www.reddit.com/login") # Reddit uses iframe for login box, so swithing to it. No needed for most other sites, this is for demonstration driver.switch_to.frame(WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.XPATH, "//*[@id='container']/div/div[1]/div[1]/iframe")))) # Selecting input field, and entering first argument as Username print(" Selecting Username field and entering Username\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input#loginUsername"))).send_keys(sys.argv[1]) # Selecting input field, and entering second argument as Password print(" Selecting Password field and entering Password\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input#loginPassword"))).send_keys(sys.argv[2]) # Clicking the Login button print(" Clicking the Login button\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.AnimatedForm__submitButton.m-full-width.m-modalUpdate"))).click() # Switching back from previous iframe to current window driver.switch_to.window(driver.window_handles[0]) # Reddit always gives annoying prompt telling us to try their app. This will click continue in browser option print(" Dismissing the Reddit prompt where they tell us to\n use their app\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.XPromoPopupRpl__actionButton"))).click() # Loading the "Comments you have received" section, which is visible only after successful login print(' Loading the "Comments you have received" section,\n which is visible only after successful login\n') driver.get("https://www.reddit.com/notification/comments") # Taking screenshot and saving it to /sdcard/Download/screenshot.png # Don't forget to give Termux storage access or else it won't be able to save print(" Taking screenshot and saving it to\n /sdcard/Download/screenshot.png\n") driver.save_screenshot("/sdcard/Download/screenshot.png") print(" Screenshot saved to Download/screenshot.jpg\n") finally: # Exit Headless Chrome driver.quit() After that, press **CRTL + X + Y + ENTER** to save and exit. Now just append the Reddit username and password when you run the python script, like this - `python reddit_screenshot_chrome.py "some_username" "the_password"` I've made it so that it prints each step so that you'll know the progress of the script. I've also added a lot of comments for you to understand what each line does. **You can also use Firefox, but I recommend using Chromium since I found it faster (by around 7s) for the same script, as well as having more know-hows. ### **For Firefox** >**Setup once:-** > >termux-setup-storage > >pkg upgrade -y > >pkg install -y tur-repo x11-repo python-pip > >pkg install -y firefox geckodriver > >pip install selenium Now to write and save the python script, do - `nano reddit_screenshot_firefox.py` Press enter, and then copy paste this - #!/data/data/com.termux/files/usr/bin/python import sys from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.firefox.options import Options from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC options = Options() options.add_argument("--headless") options.add_argument("--private-window") # Setting User-Agent to mobile to get pages as if in viewed mobile options.set_preference("general.useragent.override", "Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36") try: # Start Headless Firefox print("\n Launching Firefox (Headless mode)\n (No GUI = no resources wasted)\n") driver = webdriver.Firefox(options=options) # Setting browser size to more mobile-like dimensions print(" Setting browser size to more mobile-like dimensions\n") driver.set_window_size(driver.get_window_size()['width']/2, driver.get_window_size()['height']) # Loading url https://www.reddit.com/login print(" Loading url https://www.reddit.com/login\n") driver.get("https://www.reddit.com/login") # Reddit uses iframe for login box, so swithing to it. No needed for most other sites, this is for demonstration driver.switch_to.frame(WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.XPATH, "//*[@id='container']/div/div[1]/div[1]/iframe")))) # Selecting input field, and entering first argument as Username print(" Selecting Username field and entering Username\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input#loginUsername"))).send_keys(sys.argv[1]) # Selecting input field, and entering second argument as Password print(" Selecting Password field and entering Password\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "input#loginPassword"))).send_keys(sys.argv[2]) # Clicking the Login button print(" Clicking the Login button\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.AnimatedForm__submitButton.m-full-width.m-modalUpdate"))).click() # Switching back from previous iframe to current window driver.switch_to.window(driver.window_handles[0]) # Reddit always gives annoying prompt telling us to try their app. This will click continue in browser option print(" Dismissing the Reddit prompt where they tell us to\n use their app\n") WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.XPromoPopupRpl__actionButton"))).click() # Loading the "Comments you have received" section, which is visible only after successful login print(' Loading the "Comments you have received" section,\n which is visible only after successful login\n') driver.get("https://www.reddit.com/notification/comments") # Taking screenshot and saving it to /sdcard/Download/screenshot.png # Don't forget to give Termux storage access or else it won't be able to save print(" Taking screenshot and saving it to\n /sdcard/Download/screenshot.png\n") driver.save_screenshot("/sdcard/Download/screenshot.png") print(" Screenshot saved to Download/screenshot.jpg\n") finally: # Exit Headless Firefox driver.quit() After that, press **CRTL + X + Y + ENTER** to save and exit. Now just append the Reddit username and password when you run the python script, like this - `python reddit_screenshot_firefox.py "some_username" "the_password"` All done. Selenium is blazing fast when it comes to huge amounts of navigating, element searching, clicking, and so on. You certainly like it even more if you're a power user :-)