31 lines
709 B
Python
31 lines
709 B
Python
"""Fisture class for page functions."""
|
|
|
|
from urllib import request
|
|
from urllib.error import HTTPError
|
|
|
|
|
|
class Page:
|
|
"""Class for getting an individual page."""
|
|
|
|
def __init__(self):
|
|
"""Init function."""
|
|
self.res = None
|
|
|
|
def request_url(self, url):
|
|
"""Make a page request."""
|
|
try:
|
|
page = request.urlopen(url)
|
|
except HTTPError as err:
|
|
self.res = err
|
|
else:
|
|
with page:
|
|
self.res = page
|
|
|
|
def get_status_code(self):
|
|
"""Return the status code."""
|
|
return self.res.status
|
|
|
|
def get_header(self, header):
|
|
"""Did a session id get set."""
|
|
return self.res.headers[header]
|