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

ValueError: 'portland' is not a valid site #106

Open
chrismdavis opened this issue Feb 24, 2021 · 4 comments
Open

ValueError: 'portland' is not a valid site #106

chrismdavis opened this issue Feb 24, 2021 · 4 comments

Comments

@chrismdavis
Copy link

chrismdavis commented Feb 24, 2021

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
@irahorecka
Copy link
Contributor

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'

@chrismdavis
Copy link
Author

chrismdavis commented Feb 25, 2021 via email

@irahorecka
Copy link
Contributor

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

@juliomalegria
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants