Utils methods

Parameters:response – a requests.response object
Return type:string
Returns:cookie information as string
otodom.utils.get_csrf_token(html_content)
Parameters:html_content – a requests.response.content object
Return type:string
Returns:the CSRF token as string
otodom.utils.get_region_from_autosuggest(region_part)

This method makes a request to the OtoDom api, asking for the best fitting region for the supplied region_part string.

Parameters:region_part – input string, it should be a part of an existing region in Poland, either city, street, district or voivodeship
Return type:dict
Returns:A dictionary which contents depend on the API response.
otodom.utils.get_region_from_filters(filters)

This method does a similiar thing as scrape.utils.get_region_from_autosuggest() but instead of calling the API, it uses the data provided in the filters

Parameters:filters – dict, see scrape.category.get_category() for reference
Return type:dict
Returns:A dictionary which contents depend on the filters content.
otodom.utils.get_response_for_url(url)
Parameters:url – an url, most likely from the scrape.utils.get_url() method
Returns:a requests.response object
otodom.utils.get_url(main_category, detail_category, region, ads_per_page='', page=None, **filters)

This method builds a ready-to-use url based on the input parameters.

Parameters:
  • main_category – see scrape.category.get_category() for reference
  • detail_category – see scrape.category.get_category() for reference
  • region – see scrape.category.get_category() for reference
  • ads_per_page – ”?nrAdsPerPage=72” can be used to lower the amount of requests
  • page – page number
  • filters – see scrape.category.get_category() for reference
Return type:

string

Returns:

the url