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

Support new okcupid.com json API #63

Closed dubiousjim closed 9 years ago

dubiousjim commented 9 years ago

Two days or so ago, search requests were working fine. Then all of a sudden they changed. Now:

profiles = u.search(age_min=33,age_max=33,height_min=60,height_max=70,radius=10,last_online='month',order_by='match')
for p in profiles:
    pass

produces a long exception trace ending with:

.../site-packages/okcupyd/search.pyc in fetch(self, start_at, count)
    279                                          params=search_parameters)
    280         try:
--> 281             search_html = response.json()['html']
    282         except:
    283             log.warning(simplejson.dumps({'failure': response.content}))

.../site-packages/requests/models.pyc in json(self, **kwargs)
    791                     # used.
    792                     pass
--> 793         return json.loads(self.text, **kwargs)
    794 
    795     @property

.../site-packages/simplejson/__init__.pyc in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, use_decimal, **kw)
    503             parse_constant is None and object_pairs_hook is None
    504             and not use_decimal and not kw):
--> 505         return _default_decoder.decode(s)
    506     if cls is None:
    507         cls = JSONDecoder

.../site-packages/simplejson/decoder.pyc in decode(self, s, _w, _PY3)
    368         if _PY3 and isinstance(s, binary_type):
    369             s = s.decode(self.encoding)
--> 370         obj, end = self.raw_decode(s)
    371         end = _w(s, end).end()
    372         if end != len(s):

.../site-packages/simplejson/decoder.pyc in raw_decode(self, s, idx, _w, _PY3)
    398             elif ord0 == 0xef and s[idx:idx + 3] == '\xef\xbb\xbf':
    399                 idx += 3
--> 400         return self.scan_once(s, idx=_w(s, idx).end())

JSONDecodeError: Expecting value: line 3 column 1 (char 3)

I haven't been banned; other sorts of requests from the same account and IP still work fine. The normal web interface (accessed in a browser) has started looking different too.

colonelpanic8 commented 9 years ago

See #68 For comments.

okuser commented 9 years ago

Any progress on this issue? I am getting the same problem: JSONDecodeError: Expecting value: line 3 column 1 (char 3). when executing a simple test:

user = okcupyd.User()
profiles = user.search(age_min=26, age_max=32)
user_question = user.questions.somewhat_important[0]
for profile in profiles[:3]:
    their_question = profile.find_question(user_question.id)
    print their_question.their_answer
colonelpanic8 commented 9 years ago

there is progress but we need help

okuser commented 9 years ago

What would be useful? I'm not really familiar with the okcupyd code, but I know Python reasonably well.

colonelpanic8 commented 9 years ago

Well for starters https://github.com/IvanMalison/okcupyd/pull/68 needs to be finished

colonelpanic8 commented 9 years ago

Hey guys: I'm happy to report that as of today okcupyd now partially supports the new json api!

A bunch of work remains to get it to support all of the available filters, and that is being tracked in #70. Since this is going to be a massively breaking change, it will only be released officially as part of v1.0.0. I'm thinking about putting out a beta so people can install this, but I dont want to put out v1.0.0 until things are in a better state.

okuser commented 9 years ago

Fantastic! Thanks a lot. It already supports the features that I'm looking for at the moment.

colonelpanic8 commented 9 years ago

@okuser Are you sure? Literally the only filters that work right now are Age and gentation. See #70