Module for scraping UC Merced's class schedules
Project description
# UCMercedule: Scraper
A Python module that scrapes [UC Merced class schedules][1] for you!
Just create a `Schedule` object with `ucmscraper.Schedule(validterm)`, where `validterm` is a value from the eponymous radio button group found in the [UC Merced Schedule Search form][1]. Call `ucmscraper.fetchValidterms()` to get the current `validterm`s, or inspect the search page's raw source HTML.
## Installation
```
pipenv install ucmscraper
```
## Example usage
```python
import json
import pathlib # Python 3.5+; for pre3.5 Python, import pathlib2
import ucmscraper
pathlib.Path('./example').mkdir(exist_ok=True)
# Fall Semester 2018
# schedule = ucmscraper.Schedule(201830)
validterms = ucmscraper.fetch_validterms()
schedule = ucmscraper.Schedule(validterms[-1]) # latest term
with open('example/Fall_2018_Schedule.html', 'wb') as f:
f.write(schedule.html)
with open('example/Fall_2018_Departments.json', 'w') as f:
json.dump(schedule.departments, f, sort_keys=True, indent=4)
with open('example/Fall_2018_Sections.json', 'w') as f:
json.dump(schedule.sections, f, sort_keys=True, indent=4)
```
Check out the resulting schedule files in the [example folder](example/).
[1]: https://mystudentrecord.ucmerced.edu/pls/PROD/xhwschedule.p_selectsubject
A Python module that scrapes [UC Merced class schedules][1] for you!
Just create a `Schedule` object with `ucmscraper.Schedule(validterm)`, where `validterm` is a value from the eponymous radio button group found in the [UC Merced Schedule Search form][1]. Call `ucmscraper.fetchValidterms()` to get the current `validterm`s, or inspect the search page's raw source HTML.
## Installation
```
pipenv install ucmscraper
```
## Example usage
```python
import json
import pathlib # Python 3.5+; for pre3.5 Python, import pathlib2
import ucmscraper
pathlib.Path('./example').mkdir(exist_ok=True)
# Fall Semester 2018
# schedule = ucmscraper.Schedule(201830)
validterms = ucmscraper.fetch_validterms()
schedule = ucmscraper.Schedule(validterms[-1]) # latest term
with open('example/Fall_2018_Schedule.html', 'wb') as f:
f.write(schedule.html)
with open('example/Fall_2018_Departments.json', 'w') as f:
json.dump(schedule.departments, f, sort_keys=True, indent=4)
with open('example/Fall_2018_Sections.json', 'w') as f:
json.dump(schedule.sections, f, sort_keys=True, indent=4)
```
Check out the resulting schedule files in the [example folder](example/).
[1]: https://mystudentrecord.ucmerced.edu/pls/PROD/xhwschedule.p_selectsubject
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
ucmscraper-1.2.0.tar.gz
(3.1 kB
view hashes)
Built Distribution
Close
Hashes for ucmscraper-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 717f71541bd0ec77c4b77614899064ddbbd3b8e1e7cdeca63cb7684de845acc5 |
|
MD5 | b7e42a542a29861b9e61c0dfaa707d00 |
|
BLAKE2b-256 | d997ad46547bb703a560f0cff04997c4ab7599b1104756a8d7cc91d783b8ed00 |