Parser with BeautifulSoup, reading cookies, finding the module item links

This commit is contained in:
2025-12-05 07:45:54 +13:00
parent c8f61ef016
commit 5dff356f73
5 changed files with 164 additions and 0 deletions

26
main.py
View File

@@ -0,0 +1,26 @@
import requests
from bs4 import BeautifulSoup
# CANVAS_URL = "https://canvas.auckland.ac.nz"
CANVAS_URL = "https://canvas.auckland.ac.nz/courses/61920/modules"
def read_cookie():
with open("cookie.txt", "r") as file:
cookie = file.read().strip()
return cookie
if __name__ == "__main__":
cookie = read_cookie()
r = requests.get(
url=CANVAS_URL,
headers={
"Cookie": cookie,
})
soup = BeautifulSoup(r.text, "html.parser")
links = soup.findAll("a", {"class": "ig-title title item_link"})
print(links)