@@ -35,7 +35,7 @@ def get_request_kwargs(timeout, useragent, proxies, headers):
3535
3636
3737def get_html (url , config = None , response = None ):
38- """HTTP response code agnostic
38+ """HTTP response code agnostic
3939 """
4040 try :
4141 return get_html_2XX_only (url , config , response )
@@ -46,7 +46,7 @@ def get_html(url, config=None, response=None):
4646
4747def get_html_2XX_only (url , config = None , response = None ):
4848 """Consolidated logic for http requests from newspaper. We handle error cases:
49- - Attempt to find encoding of the html by using HTTP header. Fallback to
49+ - Attempt to find encoding of the html by using HTTP header. Fallback to
5050 'ISO-8859-1' if not provided.
5151 - Error out if a non 2XX HTTP response code is returned.
5252 """
@@ -98,12 +98,13 @@ def __init__(self, url, config=None):
9898 self .useragent = config .browser_user_agent
9999 self .timeout = config .request_timeout
100100 self .proxies = config .proxies
101+ self .headers = config .headers
101102 self .resp = None
102103
103104 def send (self ):
104105 try :
105106 self .resp = requests .get (self .url , ** get_request_kwargs (
106- self .timeout , self .useragent , self .proxies ))
107+ self .timeout , self .useragent , self .proxies , self . headers ))
107108 if self .config .http_success_only :
108109 self .resp .raise_for_status ()
109110 except requests .exceptions .RequestException as e :
0 commit comments