Skip to content
Snippets Groups Projects
Commit aaf4377c authored by borzechof99's avatar borzechof99 :whale2:
Browse files

Move Course Scraper into quiz

parent e418f64a
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,7 @@ for http://www.buchsys.de for SWP UniSport-O-Mat. ...@@ -5,6 +5,7 @@ for http://www.buchsys.de for SWP UniSport-O-Mat.
import requests import requests
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
from collections import OrderedDict
def fetch_website(url): def fetch_website(url):
...@@ -27,14 +28,14 @@ def fetch_website(url): ...@@ -27,14 +28,14 @@ def fetch_website(url):
raise raise
def scraping(site=None) -> dict: def scraping(site=None) -> OrderedDict:
""" """
Returns a dictionary of the form {name: link}, Returns a dictionary of the form {name: link},
containing the scraped content of containing the scraped content of
https://www.buchsys.de/fu-berlin/angebote/aktueller_zeitraum/index.html, https://www.buchsys.de/fu-berlin/angebote/aktueller_zeitraum/index.html,
unless another URL is given as an argument. unless another URL is given as an argument.
""" """
courses = {} courses = OrderedDict()
if site is None: if site is None:
site = "https://www.buchsys.de/fu-berlin/angebote/aktueller_zeitraum/" site = "https://www.buchsys.de/fu-berlin/angebote/aktueller_zeitraum/"
......
...@@ -3,6 +3,7 @@ Testing module, yo. Just for the course_scraper.py. ...@@ -3,6 +3,7 @@ Testing module, yo. Just for the course_scraper.py.
""" """
from django.test import TestCase from django.test import TestCase
from course_scraper import scraping # , fetch_website from course_scraper import scraping # , fetch_website
from collections import OrderedDict
class ScraperTestCase(TestCase): class ScraperTestCase(TestCase):
...@@ -15,7 +16,7 @@ class ScraperTestCase(TestCase): ...@@ -15,7 +16,7 @@ class ScraperTestCase(TestCase):
""" """
Testing return type of scraping(). Testing return type of scraping().
""" """
self.assertIsInstance(scraping(), dict) self.assertIsInstance(scraping(), OrderedDict)
def test_dict_not_empty(self): def test_dict_not_empty(self):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment