From 5e18fffba139b3960b4c6321cbb3176cb985dce3 Mon Sep 17 00:00:00 2001 From: Shubhamkar Date: Wed, 18 Jul 2018 21:57:44 +0530 Subject: [PATCH] Replaced http:// with https:// Otherwise not working in 2018. --- MooDLD.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/MooDLD.py b/MooDLD.py index 2327e86..b072fa1 100644 --- a/MooDLD.py +++ b/MooDLD.py @@ -9,7 +9,7 @@ import mechanize from Crypto.Cipher import DES -moodle = 'http://moodle.iitb.ac.in/login/index.php' +moodle = 'https://moodle.iitb.ac.in/login/index.php' # Create a browser instance br = mechanize.Browser() @@ -208,7 +208,7 @@ def __init__(self, mainlink, name, chkbox=None, directory=None, #Get nf_link for any course_object def get_nf_link(self): br.open(self.mainlink) - for link in br.links(url_regex='http://moodle.iitb.ac.in/mod/forum/view.php'): + for link in br.links(url_regex='https://moodle.iitb.ac.in/mod/forum/view.php'): if "?f=" not in link.url and not link.url.endswith('id=340'): self.nflink = link.url @@ -321,9 +321,9 @@ def login(self, username, password): br['username'] = username br['password'] = password br.submit() - if br.geturl() == 'http://moodle.iitb.ac.in/': + if br.geturl() == 'https://moodle.iitb.ac.in/': for link in \ - br.links(url_regex='http://moodle.iitb.ac.in/user/profile.php'): + br.links(url_regex='https://moodle.iitb.ac.in/user/profile.php'): self.profile = link.url br.open(self.profile) global myname @@ -339,7 +339,7 @@ def check_connection(self): ''' try: - br.open('http://moodle.iitb.ac.in/login/index.php') + br.open('https://moodle.iitb.ac.in/login/index.php') return 1 except: t.log('Could not connect to moodle, Please check your connection and try again!') @@ -412,7 +412,7 @@ def nfretrieve(self, url, directory, number): #create an array of all discussion links (self.urls) #Newer threads come first in br.links() - for link in br.links(url_regex="http://moodle.iitb.ac.in/mod/forum/discuss.php"): + for link in br.links(url_regex="https://moodle.iitb.ac.in/mod/forum/discuss.php"): if link.url == lasturl: break #breaking loop once last visited discussion/thread is encountered @@ -427,7 +427,7 @@ def nfretrieve(self, url, directory, number): br.open(url) #create an array of all downloadables - for link in br.links(url_regex="http://moodle.iitb.ac.in/pluginfile.php"): + for link in br.links(url_regex="https://moodle.iitb.ac.in/pluginfile.php"): self.nflinks.append(link) #Download all downloadables @@ -485,16 +485,16 @@ def retrieve(self, url, directory): #Find all links inside given url and form array (self.links) for link in br.links(url_regex='.'): - if (not link.url.startswith('http://moodle.iitb.ac.in/login/logout.php') + if (not link.url.startswith('https://moodle.iitb.ac.in/login/logout.php') and not link.url.startswith(br.geturl()) and not link.url.startswith('#') - and not link.url.startswith('http://moodle.iitb.ac.in/mod/forum') - and not link.url.startswith('http://moodle.iitb.ac.in/my') - and not link.url.startswith('http://moodle.iitb.ac.in/user') - and not link.url.startswith('http://moodle.iitb.ac.in/badges') - and not link.url.startswith('http://moodle.iitb.ac.in/calendar') - and not link.url.startswith('http://moodle.iitb.ac.in/grade') - and not link.url.startswith('http://moodle.iitb.ac.in/message') + and not link.url.startswith('https://moodle.iitb.ac.in/mod/forum') + and not link.url.startswith('https://moodle.iitb.ac.in/my') + and not link.url.startswith('https://moodle.iitb.ac.in/user') + and not link.url.startswith('https://moodle.iitb.ac.in/badges') + and not link.url.startswith('https://moodle.iitb.ac.in/calendar') + and not link.url.startswith('https://moodle.iitb.ac.in/grade') + and not link.url.startswith('https://moodle.iitb.ac.in/message') and link.url not in downloaded): self.links.append(link) @@ -531,7 +531,7 @@ def retrieve(self, url, directory): downloadlinks.append(link.url) else: #Retrieve from folders - if (br.geturl().startswith('http://moodle.iitb.ac.in/mod/folder') + if (br.geturl().startswith('https://moodle.iitb.ac.in/mod/folder') and link.url not in downloaded and link.text.startswith('[IMG]')): foldername = br.title()[br.title().index(':') + 2:] @@ -544,7 +544,7 @@ def retrieve(self, url, directory): self.retrieve(link.url, newpath + '/') #Retrieve Assignments - if br.geturl().startswith('http://moodle.iitb.ac.in/mod/assign') \ + if br.geturl().startswith('https://moodle.iitb.ac.in/mod/assign') \ and link.url not in downloaded: downloaded.append(link.url) if directory.endswith("Assignments/"): @@ -726,9 +726,9 @@ def load_online_courses(self): ''' Finds all links for course main pages and creates course_object objects ''' - br.open('http://moodle.iitb.ac.in/') + br.open('https://moodle.iitb.ac.in/') - for link in br.links(url_regex='http://moodle.iitb.ac.in/course/view.php'): + for link in br.links(url_regex='https://moodle.iitb.ac.in/course/view.php'): online_courses.append(course_object(link.url, link.text)) def update_from_preferences(self, n):