-
Notifications
You must be signed in to change notification settings - Fork 2
/
MPowerimageUploader.py
46 lines (39 loc) · 1.89 KB
/
MPowerimageUploader.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
import glob
import time
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
path = "/Users/akifislam/Downloads/New folder"
counter = 1
for cur_path in glob.glob(path+"/**", recursive = True):
if(cur_path.__contains__(".png") and counter>=184):
try:
fileName = (cur_path.split("/")[-1])[:-4] # to avoid double .png extension
driver = webdriver.Firefox(executable_path='/Users/akifislam/SeleniumEngines/geckodriver')
driver.get("http://moodle.mpower-social.com/converter/pix/upload.php")
driver.maximize_window()
driver.find_element(By.ID,'imgfile').send_keys(cur_path)
driver.find_element(By.ID,'imgname').send_keys(fileName)
driver.find_element(By.NAME,'submit').send_keys(Keys.RETURN)
time.sleep(.5)
print(f"{counter}. Uploaded: {fileName}")
driver.close()
except:
print("Uploading Failed Due to Bad Internet Connection")
time.sleep(40)
fileName = (cur_path.split("/")[-1])[:-4] # to avoid double .png extension
driver = webdriver.Firefox(executable_path='/Users/akifislam/SeleniumEngines/geckodriver')
driver.get("http://moodle.mpower-social.com/converter/pix/upload.php")
driver.maximize_window()
driver.find_element(By.ID, 'imgfile').send_keys(cur_path)
driver.find_element(By.ID, 'imgname').send_keys(fileName)
driver.find_element(By.NAME, 'submit').send_keys(Keys.RETURN)
time.sleep(3)
print(f"{counter}. Uploaded: {fileName}")
driver.close()
else:
print(f"{counter}. Already Uploaded !")
if(cur_path.__contains__(".png")):
counter+=1