Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. # encoding=utf8  
  2. import requests
  3. from bs4 import BeautifulSoup
  4. import fnmatch
  5. import sys
  6. import codecs
  7. import time
  8. import re
  9. import random
  10. import string
  11. from string import ascii_lowercase as al
  12. from datetime import datetime
  13. import pickle
  14. import os.path
  15.  
  16.  
  17.  
  18.  
  19.  
  20. #login                        vv                    vv
  21. login_data = dict(username='USERNAME', password='PASSWORD')
  22. headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
  23.  
  24. def innerHTML(element):
  25.     return element.decode_contents(formatter="html")
  26.  
  27.  
  28. s = requests.session()
  29. s.post('https://ultimategamer.club/account-login.php', data=login_data, headers=headers)
  30.  
  31.        
  32.        
  33.        
  34.        
  35.        
  36. link = "https://ultimategamer.club/torrents.php?cat=56"
  37.  
  38. print "1"
  39.  
  40. shit = True
  41. while shit:
  42.     r = s.get(link)
  43.     soup = BeautifulSoup(r.content,"html.parser")
  44.     titles = soup.find_all("a")
  45.     print "len"
  46.     print len(titles)
  47.     for title in titles:
  48.         if fnmatch.fnmatch(title.get("href"),"*torrents-details.php?id=*"):
  49.            
  50.             with open('titlesUGC.txt', 'a') as f:
  51.                 f.write(title.get('title').encode('ascii', 'ignore')+"\n")
  52.    
  53.     print "3"
  54.     nextlinks = titles
  55.     foundNext = False
  56.     for nextlink in nextlinks:
  57.         try:
  58.             if fnmatch.fnmatch(innerHTML(nextlink.b),"Next*"):
  59.                 foundNext = True
  60.                 link = "https://ultimategamer.club/" + str( nextlink.get('href') )
  61.                 break
  62.         except:
  63.             i = 1
  64.     print "4"
  65.     print link
  66.     if foundNext == False:
  67.         shit = False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement