diff --git a/__pycache__/import0.cpython-37.pyc b/__pycache__/import0.cpython-37.pyc new file mode 100644 index 0000000..f8fe3cd Binary files /dev/null and b/__pycache__/import0.cpython-37.pyc differ diff --git a/cc_downlaoder.py b/cc_downlaoder.py new file mode 100644 index 0000000..851b21d --- /dev/null +++ b/cc_downlaoder.py @@ -0,0 +1,6 @@ +# http://web.stanford.edu/class/archive/cs/cs103/cs103.1184/lectures/00/Slides00.pdf + +import wget + +for i in range(13): + wget.download("https://cdn.cs50.net/mobile/2018/spring/lectures/{}/lang/en/lecture{}.srt".format(i, i)) diff --git a/d.md b/d.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/d.md @@ -0,0 +1 @@ + diff --git a/download_links.py b/download_links.py new file mode 100644 index 0000000..1df97e9 --- /dev/null +++ b/download_links.py @@ -0,0 +1,41 @@ +from bs4 import BeautifulSoup, SoupStrainer +import requests +import sys + +if len(sys.argv) < 1: + print("Invalid Entry") + exit() + +url = sys.argv[1] +tempurl = url.replace("//", "") +baseurl = tempurl[:tempurl.find("/")] +print(baseurl) + + +page = requests.get(url) +data = page.text +soup = BeautifulSoup(data) + +for link in soup.find_all('a'): + if link.get('href'): + if link.get('href')[0] == "/": + print(baseurl + link.get('href')) + else: + print(link.get('href')) + + +# Full url: +# http://stackoverflow.com/questions/6038061/regular-expression-to-find-urls-within-a-string + +# Base: + +# stackoverflow.com + +# Regex: +# (http(s)?:\/\/)|(\/.*){1} + +# Example in JavaScript: + +# function toBaseURL(fullURL){ +# return fullURL.replace(/(http(s)?:\/\/)|(\/.*){1}/g, ''); +# } \ No newline at end of file diff --git a/download_links_sp.py b/download_links_sp.py new file mode 100644 index 0000000..ac7713d --- /dev/null +++ b/download_links_sp.py @@ -0,0 +1,47 @@ +from bs4 import BeautifulSoup, SoupStrainer +import requests +import sys + +if len(sys.argv) < 1: + print("Invalid Entry") + exit() + +url = sys.argv[1] +tempurl = url.replace("//", "") +baseurl = url[:tempurl.find("/") + len("//")] +print(baseurl) + + +page = requests.get(url) +data = page.text +soup = BeautifulSoup(data) + +lt = [] +for link in soup.find_all('a'): + if link.get('href'): + if link.get('href')[0] == "/" and '/file' in link.get('href'): + lt.append(baseurl + link.get('href')) + # else: + # print(link.get('href')) + +def customFn(s): + return s[s.rindex("/") + 1 : ] +lt.sort(key=customFn) +for ele in lt: + print(ele) + +# Full url: +# http://stackoverflow.com/questions/6038061/regular-expression-to-find-urls-within-a-string + +# Base: + +# stackoverflow.com + +# Regex: +# (http(s)?:\/\/)|(\/.*){1} + +# Example in JavaScript: + +# function toBaseURL(fullURL){ +# return fullURL.replace(/(http(s)?:\/\/)|(\/.*){1}/g, ''); +# } \ No newline at end of file diff --git a/import0.py b/import0.py new file mode 100644 index 0000000..cc132c7 --- /dev/null +++ b/import0.py @@ -0,0 +1,17 @@ +#from math import ceil + + + +def myFn(x): + return ceil(x) + +def ceil(x): + # only works for + + print("this is my ceil") + if x - int(x) == 0: + return x + elif x - int(x) >= 0.5: + return int(x) + 1 + else: + return int(x) + diff --git a/import1.py b/import1.py new file mode 100644 index 0000000..b29dc9f --- /dev/null +++ b/import1.py @@ -0,0 +1,6 @@ +#import math didn't work #Due to NamespaceCollxn NameError: name 'ceil' is not defined +from import0 import myFn +from math import ceil + +print(myFn(5.3)) +print(ceil(5.3)) \ No newline at end of file