Refactor to main function
This commit is contained in:
11
main.py
11
main.py
@@ -2,19 +2,19 @@ import requests
|
|||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
# CANVAS_URL = "https://canvas.auckland.ac.nz"
|
# CANVAS_URL = "https://canvas.auckland.ac.nz"
|
||||||
CANVAS_URL = "https://canvas.auckland.ac.nz/courses/61920/modules"
|
COURSE_ID = "61920"
|
||||||
|
CANVAS_URL = "https://canvas.auckland.ac.nz"
|
||||||
|
|
||||||
def read_cookie():
|
def read_cookie():
|
||||||
with open("cookie.txt", "r") as file:
|
with open("cookie.txt", "r") as file:
|
||||||
cookie = file.read().strip()
|
cookie = file.read().strip()
|
||||||
return cookie
|
return cookie
|
||||||
|
|
||||||
|
def main():
|
||||||
if __name__ == "__main__":
|
|
||||||
cookie = read_cookie()
|
cookie = read_cookie()
|
||||||
|
|
||||||
r = requests.get(
|
r = requests.get(
|
||||||
url=CANVAS_URL,
|
url=f"{CANVAS_URL}/courses/{COURSE_ID}/modules",
|
||||||
headers={
|
headers={
|
||||||
"Cookie": cookie,
|
"Cookie": cookie,
|
||||||
})
|
})
|
||||||
@@ -23,4 +23,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
links = soup.findAll("a", {"class": "ig-title title item_link"})
|
links = soup.findAll("a", {"class": "ig-title title item_link"})
|
||||||
print(links)
|
print(links)
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
||||||
Reference in New Issue
Block a user