mirror of
https://github.com/coursera-dl/coursera-dl.git
synced 2026-07-20 09:53:53 +00:00
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.
24 lines
442 B
Python
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
|