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

Any way to tell a user you visited their profile? #31

Open mconigliaro opened 9 years ago

mconigliaro commented 9 years ago

I didn't see a way to do this. I know this happens automatically for free accounts, but A-list members can browse anonymously and manually notify users that you visited their profiles. I guess a workaround for now is to just disable anonymous browsing.

colonelpanic8 commented 9 years ago

This should be really easy to add. I'll try to squeeze it into a release sometime this week.

Completely unrelated: Have you had any difficulty logging with okcupyd? Some users have reported an issue recently.

mconigliaro commented 9 years ago

Nope, it's been working fine. I just made a little wrapper script to activate the virtualenv and set the appropriate env vars before running my python script.

$ cat ./run.sh
#!/usr/bin/env bash

source ./bin/activate
export OKC_USERNAME='<username>'
export OKC_PASSWORD='<password>'
exec ./run.py
colonelpanic8 commented 9 years ago

Thats good to hear. You should be aware that okcupid recently deleted all of my accounts (and those of the people with whom I share internet) and banned my ip address (and any ip address from which a login attempt to my address is made) from logging in to okcupid at all.

If you are doing things that could potentially make okcupid unhappy from an okcupid account that you care about, I would recommend that you use http://okcupyd.readthedocs.org/en/latest/public.html#okcupyd.profile_copy.Copy to backup your profile. You can also very easily do most okcupid access through a dummy account to avoid drawing attention to any accounts you care about.

mconigliaro commented 9 years ago

Good to know. For what it's worth, I've just been doing searches and visiting profiles so far. I've also inserted a random 5-15 second delay between each request to avoid suspicion and/or flooding the servers.

mconigliaro commented 9 years ago

Not sure if this helps, but A-list members get a little button that says "Let them know I visited." The HTML source looks like this:

<button class="flatbutton white" onclick="Profile.visit('<username>')"> Let them know I visited </button>

Clicking on it sends a POST to www.okcupid.com/profile with the following form data: ajax=1&u=<username>&tuid=<some digits>&stalk=1

colonelpanic8 commented 9 years ago

yeah. this should be a feature that is super easy to add. I would encourage you to take a stab at it. The value for tuid is just the id attribute of the Profile object. Profile objects already have a requests session, so all you really need to do is something like

self._session.okc_post('profile', data={'ajax': 1, 'username': self.username, 'tuid': self.id, 'stalk': 1})
colonelpanic8 commented 9 years ago

@mconigliaro /anyone else who is interested in this feature. Can you test https://github.com/IvanMalison/okcupyd/tree/stalk_profile to make sure it works? It would be super cool if you could also record the vcrpy cassette that is used in testing for the test_stalk test.

This should simply amount to putting your credentials in the file test_credentials.py, and then run inv r test_stalk. Obviously your credentials will be scrubbed from the recording. (the code that does this lives here: https://github.com/IvanMalison/okcupyd/blob/master/okcupyd_testing/util.py#L62)

chrism2671 commented 9 years ago

I found that doing profile.gender() seems to create the request you desire (that is, appear in their visitor logs).

colonelpanic8 commented 9 years ago

@chrism2671

chrism2671 commented 9 years ago

Ah my mistake!

Out of curiosity, why is this 'unfortunate'?

Incidentally, have you been banned by OKC yet? Just trying to understand what suitably conservative behaviour is.

colonelpanic8 commented 9 years ago

Out of curiosity, why is this 'unfortunate'?

@chrism2671 It's unfortunate because that it means that simply using this library with an unpaid account will result in lots of possibly unintended profile views. That is why i decided to delay the retrieval of profile information to the last possible moment.

Incidentally, have you been banned by OKC yet? Just trying to understand what suitably conservative behaviour is.

Yes, as I mentioned above, all of the accounts, as well as my home IP address have been banned from okcupid. The behavior of some of my accounts was highly irregular (beyond what most people would typically use this library for), and I imagine that simply using okcupyd to, for example, backup all of your messages or something like that will not incur okcupid's wrath. If you want to do stuff that involves on the order of 100s or 1000s of profiles/requests, I would advise some caution. Using the profile copy functionality is another thing that could get you banned.

colonelpanic8 commented 9 years ago

@chrism2671if you could help test this feature I would really appreciate it. Do you have an a-list account?

chrism2671 commented 9 years ago

Sorry for the delay, been on holiday! I don't have an A-list account at the moment, but I might sign up for one in due course.

In my script, that involves visiting a lot of profiles repeatedly, I inserted:

import random
import time
sleep_time = random.gauss(10,5)
time.sleep(sleep_time)

between requests, which seemed to keep okc happy (for now).

dubiousjim commented 9 years ago

Good to know they've started banning accounts. I was using 2-4 second delays between requests to profiles. This is a good motivation for issue #44.