-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
KrKOo
committed
Mar 14, 2022
1 parent
921bcd3
commit 2296d53
Showing
10 changed files
with
178 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
end_of_line = lf | ||
max_line_length = off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"manifest_version": 2, | ||
"version": "1.0.1", | ||
"name": "VUT FIT video server addon", | ||
"description": "VUT FIT video server addon for showing lecture titles and week numbering", | ||
"content_scripts": [ | ||
{ | ||
"matches": ["https://video1.fit.vutbr.cz/*"], | ||
"js": ["main.js"] | ||
} | ||
], | ||
"permissions": ["*://fitscrap.herokuapp.com/*"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
*_cache.sqlite | ||
|
||
# Editors | ||
.vscode/ | ||
.idea/ | ||
|
||
# Vagrant | ||
.vagrant/ | ||
|
||
# Mac/OSX | ||
.DS_Store | ||
|
||
# Windows | ||
Thumbs.db | ||
|
||
# Source for the following rules: https://raw.githubusercontent.com/github/gitignore/master/Python.gitignore | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: python server.py |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import requests | ||
from bs4 import BeautifulSoup | ||
|
||
|
||
def getAllCourseIDs(): | ||
URL = "https://www.fit.vut.cz/study/courses/.cs" | ||
|
||
page = requests.get(URL) | ||
soup = BeautifulSoup(page.content, "html.parser") | ||
courseTDs = soup.select("table#list tbody tr td:nth-child(2)") | ||
courseIDs = [element.text for element in courseTDs] | ||
|
||
return courseIDs | ||
|
||
|
||
def getLectureTitles(courseID): | ||
URL = "https://www.fit.vut.cz/study/course/{}/.cs".format(courseID) | ||
|
||
courseIDs = getAllCourseIDs() | ||
|
||
if courseID not in courseIDs: | ||
return | ||
|
||
page = requests.get(URL) | ||
soup = BeautifulSoup(page.content, "html.parser") | ||
labelArray = soup.select('p:-soup-contains("Osnova přednášek")') | ||
|
||
if not labelArray: | ||
return [] | ||
|
||
label = labelArray[0] | ||
titleListContainer = label.findNext("div") | ||
titlesListItems = titleListContainer.findAll("li") | ||
titles = [element.text for element in titlesListItems] | ||
|
||
return titles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
appdirs==1.4.4 | ||
attrs==21.4.0 | ||
beautifulsoup4==4.10.0 | ||
cattrs==1.10.0 | ||
certifi==2021.10.8 | ||
charset-normalizer==2.0.12 | ||
click==8.0.4 | ||
Flask==2.0.3 | ||
Flask-Cors==3.0.10 | ||
idna==3.3 | ||
itsdangerous==2.1.1 | ||
Jinja2==3.0.3 | ||
MarkupSafe==2.1.0 | ||
python-dotenv==0.19.2 | ||
requests==2.27.1 | ||
requests-cache==0.9.3 | ||
six==1.16.0 | ||
soupsieve==2.3.1 | ||
url-normalize==1.4.3 | ||
urllib3==1.26.8 | ||
Werkzeug==2.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
from flask import Flask, jsonify | ||
from flask_cors import CORS | ||
from dotenv import load_dotenv | ||
import requests_cache | ||
|
||
from Scrapper.scrapper import getLectureTitles | ||
|
||
load_dotenv() | ||
requests_cache.install_cache("requests_cache", backend="sqlite") | ||
|
||
app = Flask(__name__) | ||
CORS(app) # enable CORS for all routes | ||
|
||
|
||
@app.route("/") | ||
def root(): | ||
return "<h1>VUT FIT website scrapper.</h1>" | ||
|
||
|
||
@app.route("/lecture-titles/<courseID>") | ||
def lectureTitles(courseID): | ||
titles = getLectureTitles(courseID) | ||
return jsonify(titles) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(host=os.getenv("HOST"), port=os.getenv("PORT")) |