From 3a421d15d180ccd6d8eec0b3060a768174a83336 Mon Sep 17 00:00:00 2001 From: Varin6 Date: Sun, 11 Sep 2022 15:15:50 +0100 Subject: [PATCH] Adding proxies optional argument --- rightmove_webscraper/scraper.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rightmove_webscraper/scraper.py b/rightmove_webscraper/scraper.py index 12acc0b..cbe5da2 100644 --- a/rightmove_webscraper/scraper.py +++ b/rightmove_webscraper/scraper.py @@ -16,7 +16,7 @@ class RightmoveData: The query to rightmove can be renewed by calling the `refresh_data` method. """ - def __init__(self, url: str, get_floorplans: bool = False): + def __init__(self, url: str, get_floorplans: bool = False, proxies: dict = None): """Initialize the scraper with a URL from the results of a property search performed on www.rightmove.co.uk. @@ -26,14 +26,15 @@ def __init__(self, url: str, get_floorplans: bool = False): floor plan images for each listing (be warned this drastically increases runtime so is False by default). """ - self._status_code, self._first_page = self._request(url) + self._proxies = proxies + self._status_code, self._first_page = self._request(url, proxies) self._url = url self._validate_url() self._results = self._get_results(get_floorplans=get_floorplans) @staticmethod - def _request(url: str): - r = requests.get(url) + def _request(url: str, proxies: dict = None): + r = requests.get(url, proxies=proxies) return r.status_code, r.content def refresh_data(self, url: str = None, get_floorplans: bool = False):