charliewolf / pynder

:fire: Python client for tinder api
Other
638 stars 142 forks source link

user.instagram_username() returns "Tinder" -- fix #207

Open MMcintire96 opened 5 years ago

MMcintire96 commented 5 years ago

Here is my proposed fix, if someone wants to make it use the python standard html.parser library that would be much appreciated. Also code is not tested formally but seems to work for most situations (picture, private_user, normal_user).

import requests
from bs4 import BeautifulSoup
import re
def instagram_username(self):
    if "instagram" in self._data:
        x = requests.get(self._data['instagram']['photos'][0]['link']).text
        soup = BeautifulSoup(x, 'html5lib')
        meta_str = soup.find('meta',
                 attrs={'property': 'og:description'})['content']
        ig_uname = re.findall('@[^\s|\W]*', meta_str)
        return ig_uname[0][1:]
        #return self._data['instagram']['username']
seteBR commented 5 years ago

Still working? Got an error.

x = requests.get(self._data['instagram']['photos'][0]['link']).text

KeyError: 'link'

MMcintire96 commented 5 years ago

No, it appears that the api has changed and now the Instagram[] does not contain "photos". I searched through the useable content in Instagram[] ("image", "thumbnail" and "profile_photo") but they all appear to be links to the cdn. The cdn's page has no way of locating the user.

I think this has been changes with FB/IG's protocol rather than Tinder's, but unfortunately I can't find any way to get instagram_username anymore.