|
| 1 | +#!/usr/bin/env python |
| 2 | + |
| 3 | +import base |
| 4 | +import os |
| 5 | +import requests |
| 6 | +import sys |
| 7 | +import urllib |
| 8 | + |
| 9 | +from termcolor import colored |
| 10 | +from bs4 import BeautifulSoup |
| 11 | + |
| 12 | + |
| 13 | +# Control whether the module is enabled or not |
| 14 | +ENABLED = True |
| 15 | + |
| 16 | + |
| 17 | +class style: |
| 18 | + BOLD = '\033[1m' |
| 19 | + END = '\033[0m' |
| 20 | + |
| 21 | + |
| 22 | +def banner(): |
| 23 | + print(colored(style.BOLD + '\n[+] Checking Tinder for username\n' |
| 24 | + + style.END, 'blue')) |
| 25 | + |
| 26 | + |
| 27 | +def fetch_content(username): |
| 28 | + r = requests.get('https://gotinder.com/@{}'.format(username)) |
| 29 | + content = BeautifulSoup(r.content, 'lxml') |
| 30 | + return content |
| 31 | + |
| 32 | + |
| 33 | +def check_useranme_exists(content): |
| 34 | + if content.find(id='card-container'): |
| 35 | + return True |
| 36 | + else: |
| 37 | + return False |
| 38 | + |
| 39 | + |
| 40 | +def parse_page(content): |
| 41 | + userinfo = { |
| 42 | + 'name': str(content.find(id='name').text), |
| 43 | + 'age': content.find(id='age').text.encode('utf-8').strip(',\xc2\xa0'), |
| 44 | + 'picture': str(content.find(id='user-photo').get('src')), |
| 45 | + 'teaser': str(content.find(id='teaser').text), |
| 46 | + } |
| 47 | + return userinfo |
| 48 | + |
| 49 | + |
| 50 | +def download_photo(username, url): |
| 51 | + file_path = str('profile_pic/{}'.format(username)) |
| 52 | + if not os.path.exists(file_path): |
| 53 | + os.makedirs(file_path) |
| 54 | + path = file_path + "/tinder." + url.split('.')[-1] |
| 55 | + urllib.urlretrieve(url, path) |
| 56 | + |
| 57 | + |
| 58 | +def main(username): |
| 59 | + userinfo = {} |
| 60 | + content = fetch_content(username) |
| 61 | + if check_useranme_exists(content): |
| 62 | + userinfo = parse_page(content) |
| 63 | + download_photo(username, str(content.find(id='user-photo').get('src'))) |
| 64 | + return userinfo |
| 65 | + |
| 66 | + |
| 67 | +def output(data, username=""): |
| 68 | + if len(data) is 0: |
| 69 | + print('username not found') |
| 70 | + else: |
| 71 | + for k, v in data.iteritems(): |
| 72 | + print('{k}: {v}'.format(k=k.capitalize(), v=v)) |
| 73 | + |
| 74 | + |
| 75 | +if __name__ == "__main__": |
| 76 | + try: |
| 77 | + username = sys.argv[1] |
| 78 | + banner() |
| 79 | + result = main(username) |
| 80 | + output(result, username) |
| 81 | + except Exception as e: |
| 82 | + print e |
| 83 | + print "Please provide a username as argument" |
0 commit comments