python-craigslist icon indicating copy to clipboard operation
python-craigslist copied to clipboard

ValueError: 'portland' is not a valid site

Open chrismdavis opened this issue 5 years ago • 4 comments

Getting the following error including when ran with default site 'sfbay'. Was working as recent as yesterday: Thanks

cl_h = CraigslistHousing(site='portland', category='apa',
                         filters={'max_price': 2000, 
                                  'min_price': 1200,
                                  'posted_today': True,
                                  'search_distance': 15,
                                  'zip_code': 97215,
                                  'housing_type': 'house'})
'portland' is not a valid site
'portland' is not a valid site
'portland' is not a valid site
'portland' is not a valid site
'portland' is not a valid site
Traceback (most recent call last):

  File "<ipython-input-9-da0a94b31916>", line 1, in <module>
    cl_h = CraigslistHousing(site='portland', category='apa',

  File "C:\Users\addas\anaconda3\lib\site-packages\craigslist\base.py", line 63, in __init__
    raise ValueError(msg)

ValueError: 'portland' is not a valid site

chrismdavis avatar Feb 24 '21 16:02 chrismdavis

Hey @chrismd1, so first of all, housing_type is not a valid filter. The resulting url generated by your query is https://portland.craigslist.org/search/apa?searchNearby=1&max_price=2000&min_price=1200&postedToday=1&search_distance=15&postal=97215&s=0

Unfortunately, it seems like Craigslist blocked my IP address (HTTP 403 Forbidden client error). You can try this to see if you have the same results:

import requests
search_url = "https://portland.craigslist.org/search/apa?searchNearby=1&max_price=2000&min_price=1200&postedToday=1&search_distance=15&postal=97215&s=0"

print(requests.get(search_url).status_code)
print(requests.get(search_url).text)

>>> 403
>>> 'This IP has been automatically blocked.\nIf you have questions, please email: [email protected]\n'

irahorecka avatar Feb 24 '21 18:02 irahorecka

Hi Ira,

Thanks for responding. Of note - the example code from the package information page https://pypi.org/project/python-craigslist/ also returns the same result ('...ValueError: 'sfbay' is not a valid site'). I've removed the 'housetype' filter and still can't avoid this error.

from craigslist import CraigslistHousing

cl_h = CraigslistHousing(site='sfbay', area='sfc', category='roo', filters={'max_price': 1200, 'private_room': True})

You can get an approximate amount of results with the following call:

print(cl_h.get_results_approx_count())

Thanks, Chris

On Wed, Feb 24, 2021 at 10:01 AM Ira Horecka [email protected] wrote:

Hey @chrismd1 https://github.com/chrismd1, so first of all, housing_type is not a valid filter. The resulting url generated by your query is https://portland.craigslist.org/search/apa?searchNearby=1&max_price=2000&min_price=1200&postedToday=1&search_distance=15&postal=97215&s=0

Unfortunately, it seems like Craigslist blocked my IP address (HTTP 403 Forbidden client error). You can try this to see if you have the same results:

import requestssearch_url = "https://portland.craigslist.org/search/apa?searchNearby=1&max_price=2000&min_price=1200&postedToday=1&search_distance=15&postal=97215&s=0" print(requests.get(search_url).status_code)print(requests.get(search_url).text)

403>>> 'This IP has been automatically blocked.\nIf you have questions, please email: [email protected]\n'

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/juliomalegria/python-craigslist/issues/106#issuecomment-785264695, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGSL2RJPELJJ4TEUR6RZS23TAU5JHANCNFSM4YE3AJ6A .

chrismdavis avatar Feb 25 '21 15:02 chrismdavis

Hey @chrismd1 I apologize, my maladies was tied with issue #105. Is your issue still persistent?

irahorecka avatar Mar 11 '21 04:03 irahorecka

Hey @chrismd1.

I just tried this and this works just fine for me.

Can you run this to double-check that the library is getting the sites correctly?

In [1]: from craigslist import utils

In [2]: len(utils.get_all_sites())
Out[2]: 708

Can you try that and tell me what you get? Thanks.

juliomalegria avatar Aug 20 '21 10:08 juliomalegria