Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.74 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import time
  4. import sys
  5. import os
  6. import requests
  7. import re
  8. import random
  9. import getpass
  10. import cfscrape
  11.  
  12. ##
  13. ## CONFIG VARIABLES : YOU CAN EDIT THESE VARIABLES TO CHANGE TIMER VALUES ##
  14. ##
  15. MIN_DELAY_BETWEEN_PROFILE_VIEWS = 1
  16. MAX_DELAY_BETWEEN_PROFILE_VIEWS = 3
  17. DELAY_BETWEEN_RUNS = 5
  18. sex = 'FEMALE' # Possible values: 'MALE', 'FEMALE', or empty '' for both
  19. age1 = 18 # minimum age
  20. age2 = 25 # maximum age
  21.  
  22. # We keep already visited profile in a file to avoid visiting
  23. # a profile multiple times on consecutive execution of this script
  24. # YOU CAN DELETE THIS FILE IF YOU WANT TO VISIT EVERYBODY ONCE AGAIN
  25. visitedUsersFilename = 'users_visited.txt'
  26.  
  27. # Set this variable to True to output debug log,
  28. # or False for more concise output
  29. DEBUG = True
  30. ##
  31. ## END OF CONFIG VARIABLES
  32. ##
  33.  
  34. offset1 = 0
  35. offset2 = 0
  36. sessioncount = 0
  37. run_number = 1
  38. f = open(visitedUsersFilename, 'a+')
  39. processedUsers = [line.strip() for line in f]
  40. print ("Already processed" + str(len(processedUsers)) + ' users.')
  41.  
  42. countrycode = input('\nCountry code (e.g. Germany = DE): ' )
  43. countrycode = countrycode.upper()
  44.  
  45.  
  46. onlinestatus = input('View online members only? (Y/N): ')
  47. onlinestatus = onlinestatus.upper()
  48. if onlinestatus == 'Y':
  49.     onlinestatus='true'
  50. else:
  51.     onlinestatus='false'
  52.    
  53. s = cfscrape.CloudflareScraper(js_engine='Node')
  54. login = input('Username (): ')
  55. password = getpass.getpass('Password: ')
  56. payload = {'action': 'login',
  57.            'login': login,
  58.            'auto_login' : '0',
  59.            'password': password}
  60.  
  61. print ("Logging in...")
  62.  
  63. s.get("https://www.interpals.net/app/auth/login")
  64. r = s.post("https://www.interpals.net/app/auth/login", data=payload)
  65. print ("Logged in: Starting the dance \o/")
  66. time.sleep(2)
  67. #print r.headers
  68. #print r.text
  69. while True:
  70.     runcount = 0
  71.     if DEBUG:
  72.         print("Fetching the search page...")
  73.     r = s.get('https://www.interpals.net/app/search?todo=search&sort=last_login&age1=%d&age2=%d&sex[0]=%s&photo=1&online=%s&countries[0]=---&countries[0]=%s&offset=%d&offset=%d' % (age1, age2, sex, onlinestatus, countrycode, offset1, offset2))
  74.     data = r.text
  75.     print(data)
  76.     for m in re.finditer('<b><a href=', data):
  77.         username = data[m.start()+13:m.start()+28]
  78.         if '?' in username:
  79.             mesto = username.index('?')
  80.             username = username[:mesto]
  81.  
  82.         if username not in processedUsers:
  83.             if DEBUG:
  84.                 print ('Visiting profile of ' + username + ' (' + str(sessioncount) + ')')
  85.             runcount += 1
  86.             sessioncount += 1
  87.             r = s.get('https://www.interpals.net/' + username)
  88.             waitTime = random.randrange(MIN_DELAY_BETWEEN_PROFILE_VIEWS*10, MAX_DELAY_BETWEEN_PROFILE_VIEWS*10) / float(10)
  89.             if DEBUG:
  90.                 print ('Waiting ' + str(waitTime) + 's')
  91.             else:
  92.                 os.system('cls' if os.name=='nt' else 'clear')
  93.                 print ('\rRun %d - Fetched %d users (%d total)' % (run_number, runcount, sessioncount))
  94.             time.sleep(waitTime)
  95.             processedUsers.append(username)
  96.             f.write(username + '\n')
  97.         elif DEBUG:
  98.             print ('Already visited ' + username)
  99.     run_number += 1
  100.     offset1=offset1+20
  101.     offset2=offset1+20
  102.     if (runcount < 20):
  103.         print ('[-] Waiting (%d)s before next run (fetched %d users this run, %d total)\n' % (DELAY_BETWEEN_RUNS, runcount, sessioncount))
  104.         time.sleep(DELAY_BETWEEN_RUNS)
  105.     else:
  106.         print ('[+] Waiting (%d)s before next run (fetched %d users this run, %d total)\n' % (DELAY_BETWEEN_RUNS, runcount, sessioncount))
  107.         time.sleep(DELAY_BETWEEN_RUNS)
  108.  
  109. # This script is ugly. It was made rapidly, for fun. At least, it does its job.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement