colonelpanic8 / okcupyd

A Library that enables programmatic interaction with okcupid.com, using okcupid.com's private okcupid JSON API and html scraping when necessary.
MIT License
110 stars 18 forks source link

Search no longer works (404), login may be broken as well #84

Open odkken opened 8 years ago

odkken commented 8 years ago

Seems logging in now returns a status_str: 'Sorry, Staff Robot had a meltdown—check back later' (not sure if this matters, login still seems to technically work)

On performing a search (from the example search.py), a 404 error is always returned.

colonelpanic8 commented 8 years ago

Here is the relevant traceback

HTTPError                                 Traceback (most recent call last)
/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/tasks/__init__.pyc in <module>(
)                                                                                                      
----> 1 u.search()

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/user.pyc in search(self, **kwar
gs)                                                                                                    
    160             count = kwargs.pop('count')
    161             return search(session=self._session, count=count, **kwargs)
--> 162         return SearchFetchable(self._session, **kwargs)
    163 
    164     def delete_threads(self, thread_ids_or_threads):

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/json_search.pyc in SearchFetcha
ble(session, **kwargs)                                                                                 
     35     return util.Fetchable(
     36         SearchManager(
---> 37             SearchJSONFetcher(session, **kwargs),
     38             ProfileBuilder(session)
     39         )

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/json_search.pyc in __init__(sel
f, session, **options)                                                                                 
     82         self._session = session or Session.login()
     83         self._options = options
---> 84         self._parameters = search_filters.build(session=self._session, **options)
     85 
     86     def _get_headers(self):

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/filter.pyc in build(self, **kwa
rgs)                                                                                                   
    153         return {
    154             builder.output_key: builder.transform_from_kwargs(kwargs)
--> 155             for builder in self.builders
    156             if builder.decide(kwargs)
    157         }

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/filter.pyc in <dictcomp>((build
er,))                                                                                                  
    154             builder.output_key: builder.transform_from_kwargs(kwargs)
    155             for builder in self.builders
--> 156             if builder.decide(kwargs)
    157         }
    158 

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/filter.pyc in transform_from_kw
args(cls, kwargs)                                                                                      
     48 
     49             def transform_from_kwargs(cls, kwargs):
---> 50                 return cls.transform(*[kwargs.get(key) for key in cls.keys])
     51 
     52             def _set_defaults(cls):

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/json_search.pyc in transform(lo
cation, location_cache)                                                                                
    213     # injection. A better solution is probably needed long term
    214     def transform(location, location_cache):
--> 215         return location_cache.get_locid(location)
    216 
    217 

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/location.pyc in get_locid(self,
 query)                                                                                                
     16         if query in self._query_cache:
     17             return self._query_cache[query]
---> 18         result = self._query(query)
     19         if 'results' in result and len(result['results']):
     20             locid = result['results'][0]['locid']

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/location.pyc in _query(self, qu
ery)                                                                                                   
     32         return self._session.okc_get(
     33             'apitun/location/query',
---> 34             params={'q': query, 'access_token': self._session.access_token},
     35         ).json()

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/okcupyd/session.pyc in okc_method(self,
 path, secure, **kwargs)                                                                               
    132         self.rate_limiter.wait()
    133         response = base_method(self.build_path(path, secure), **kwargs)
--> 134         response.raise_for_status()
    135         return response
    136     return okc_method

/usr/local/var/pyenv/versions/2.7.12/lib/python2.7/site-packages/requests/models.pyc in raise_for_statu(
self)                                                                                                  
    849 
    850         if http_error_msg:
--> 851             raise HTTPError(http_error_msg, response=self)
    852 
    853     def close(self):

HTTPError: 404 Client Error: 

The request that is failing is actually the request to get the location ID. It seems that this endpoint has been expired.

def transform(location, location_cache):
    return location_cache.get_locid(location)

We need to figure out if this just been completely eliminated or changed in some way.

colonelpanic8 commented 8 years ago

This should be fixed now. Can you confirm @odkken .

odkken commented 8 years ago

Did a fresh clone and am actually seeing issue #79 again now. I think I had commented out the imports before, but since I see it's been reported I figured I'd bring it up.

Also, I'm having trouble installing the requirements (looks like it has to do with the ~= version specification?) using pycharm's auto install feature. I think it was trying to use anaconda on windows, and on linux it's using pip/setuptools (none of which succeed).

colonelpanic8 commented 8 years ago

@odkken you shouldn't be getting #79 on the latest version since the line that was causing it is gone from the repository.

odkken commented 8 years ago

Here's the stack trace I get when running the search:

Traceback (most recent call last): File "/root/okc2.7/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2869, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 4, in import okcupyd File "/home/moltar/pycharm-community-2016.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import module = self._system_import(name, _args, _kwargs) File "/root/okc2.7/local/lib/python2.7/site-packages/okcupyd/init.py", line 8, in from . import tasks File "/home/moltar/pycharm-community-2016.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import module = self._system_import(name, _args, _kwargs) File "/root/okc2.7/local/lib/python2.7/site-packages/okcupyd/tasks/init.py", line 7, in from . import db as db_collection File "/home/moltar/pycharm-community-2016.2/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import module = self._system_import(name, _args, *_kwargs) File "/root/okc2.7/local/lib/python2.7/site-packages/okcupyd/tasks/db.py", line 15, in @task(default=True) File "/root/okc2.7/local/lib/python2.7/site-packages/invoke/tasks.py", line 303, in inner autoprint=autoprint, File "/root/okc2.7/local/lib/python2.7/site-packages/invoke/tasks.py", line 58, in init self.positional = self.fill_implicit_positionals(positional) File "/root/okc2.7/local/lib/python2.7/site-packages/invoke/tasks.py", line 149, in fill_implicit_positionals args, spec_dict = self.argspec(self.body) File "/root/okc2.7/local/lib/python2.7/site-packages/invoke/tasks.py", line 144, in argspec raise TypeError("Tasks must have an initial Context argument!") TypeError: Tasks must have an initial Context argument!

Just cloned this today, on master.

colonelpanic8 commented 8 years ago

its probably importing it from the wrong place. or maybe getting the tasks list from the wrong place, or perhaps you have an old version of invoke.

Don't clone okcupyd like that

you should install it with the command mentioned in the README (unless your plan on actually developing it yourself).