A web crawler library that fetches and parses data from Boston College Agora Portal
Project description
pygora
A web crawler library that fetches and parses data from BC Agora Portal.
To Install (needs Python 3):
pip install pygora-phchcc
To Run:
example: download and store all subject links with corresponding school code & subject code (the username and password will not be cached locally)
from pygora import *
session, gen_time = get_session("myAgoraUsername", "myAgoraPassword", check_valid=True)
# if gen_time == 0, we know something goes wrong (maybe you did not input the correct credential)
subjects = download_subjects(session, simple=True)
# subjects = download_subjects(session) # get you the full information
with open("subjects.txt", "w") as f:
for line in subjects:
print(line)
f.write(line + "\n")
cache the username and password so that you don't have to write them explicitly in a script
from pygora import *
# to set credential, run it once so that username & password are stored locally
set_credential("myAgoraUsername", "myAgoraPassword")
# to clear out credential
set_credential("", "")
example of parse_subject_page
: print out all biology courses (school and subject codes can be found in subject.txt
), provided that if you have run set_credential
from pygora import *
session, gen_time = get_session(*get_credential(), check_valid=True)
# if you are confident that your username & password are correct, do
# session, gen_time = get_session(*get_credential())
url = SUBJECT_URL.format('2MCAS', '2BIOL') # get you a url string
resp = session.get(url) # use your session to HTTP get the url
courses = parse_subject_page(resp) # parse the subject page
for course in courses:
print(course)
example of parse_course_page
: print all information on a course page (the course code can be found in the output of parse_subject_page
)
from pygora import *
session, gen_time = get_session(*get_credential())
url = COURSE_URL.format('ACCT102101')
# a dummy dict in this example, could be your data fetched from database
info_dict = dict()
resp = session.get(url)
parse_course_page(resp, info_dict) # update the dict
for key, value in info_dict.items():
print(key, value)
Used by
the backend of EagleVision
the backend of New PEPS (planning)
Join Dev Team / Contact Us:
open an issue on Github to announce the feature/bug that you want to work on
or through email: (Haochen) phchcc_at_gmail_dot_com
or search our names in BC directory
Special Thanks
Special thanks to people who made EagleVision (this project's prototype) and pygora alive (names are listed in alphabetical order):
Ashkan Moghaddassi -- provides code reviews
Baichuan (Patrick) Guo -- the original "Honest Team"
Cecilia Wu -- awesome idea inputs
David Shen -- the EagleVision Dev Team
Estevan Feliz -- the original "Honest Team" & the EagleVision Dev Team
Jacob Wolf -- provides code reviews
Jianxin (Jeff) Wang -- provides code reviews
Roger Wang -- the EagleVision Dev Team
Yingjian (Steven) Wu -- awesome idea inputs
Yuning (Tommy) Yang -- the original "Honest Team"
Yuxuan (Jacky) Jin -- the EagleVision Dev Team
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pygora-phchcc-0.0.5.tar.gz
(6.4 kB
view hashes)
Built Distribution
Close
Hashes for pygora_phchcc-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0a4daa3f7ff1fa121d4f1b8e07f7fe1d075c29de3554862f877470af785724c |
|
MD5 | 165edc5500dc4757d51732983a20666b |
|
BLAKE2b-256 | fbe6c2364857beacd8fdbeafe7cdba6df17b421667bfbd308072db7a087fcdca |