To start with, we need to import some packages:
import refrom weatherterm.core import Forecastfrom weatherterm.core import Requestfrom weatherterm.core import Unitfrom weatherterm.core import UnitConverter
And in the initializer, we are going to add the following code:
self._base_url = 'http://weather.com/weather/{forecast}/l/{area}'self._request = Request(self._base_url)self._temp_regex = re.compile('([0-9]+)\D{,2}([0-9]+)')self._only_digits_regex = re.compile('[0-9]+')self._unit_converter = UnitConverter(Unit.FAHRENHEIT)
In the initializer, we define the URL template we are going to use to perform requests to the weather website; then, we create a Request object. This is the object that will perform the requests for ...