Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding proxies optional argument #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions rightmove_webscraper/scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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):
Expand Down