coursera-dl/coursera/network.py
Yuri Bochkarev 71b1d643c9 Extract supplementary files from [un]gradedProgramming sections
I also moved a couple of methods into a separate class CourseraOnDemand
to encapsulate all the tricks that are performed to extract links to
different types of resources.
2016-01-29 21:58:12 +03:00

24 lines
442 B
Python

"""
This module contains utility functions that operate on the network, download
some data and so on.
"""
import logging
import requests
def get_page(session, url):
"""
Download an HTML page using the requests session.
"""
r = session.get(url)
try:
r.raise_for_status()
except requests.exceptions.HTTPError as e:
logging.error("Error %s getting page %s", e, url)
raise
return r.text