Advertisement
Guest User

Untitled

a guest
Mar 18th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. # IMPORTANT THINGS:
  3. # Made for Python 2.7
  4. # REQUIRES BeatifulSoup4 (pip install beatifulsoup4)
  5.  
  6. import requests
  7. import re
  8. import hashlib
  9. from bs4 import BeautifulSoup
  10.  
  11. forumThread = "4243377-b-steam-spiele-s-bietet-mir"                                                         # Thread ID + name (ex: "4239749-cheap-steam-game-shop")
  12.  
  13. print("Hello world!\n")                                              
  14. fullURL = "http://www.elitepvpers.com/forum/elite-gold-trading/" + forumThread + ".html"                    # Formats the URL
  15. print("Read URL as: " + fullURL + "\n")
  16.  
  17. Username = ""
  18. Password = ""
  19.  
  20. loginURL = "http://www.elitepvpers.com/forum/login.php?do=login"
  21. pwmd5 = hashlib.md5(Password.encode("UTF-8")).hexdigest()
  22.  
  23. print("Password hashed as: " + pwmd5 + "\n")
  24.  
  25. payload = {
  26.     "vb_login_username": Username,
  27.     "s": "",
  28.     "securitytoken": "guest",
  29.     "do": "login",
  30.     "vb_login_md5password": pwmd5,
  31.     "vb_login_md5password_utf": pwmd5
  32. }
  33. headers = {
  34.     "Referer": "http://www.elitepvpers.com/forum/"
  35. }
  36.  
  37. with requests.Session() as s:
  38.     pwmd5 = hashlib.md5(Password.encode("UTF-8")).hexdigest()
  39.     p = s.post(loginURL, data=payload, headers=headers)
  40.     r = s.get(fullURL)
  41.     output = open("output.html", "w")
  42.     output.write(r.text.encode("ISO-8859-1", "ignore"))
  43.     output.close()
  44.     soup = BeautifulSoup(r.text, "html.parser")
  45.     posts = soup.findAll("div", {"itemprop": "text"})
  46.  
  47.     for nya in posts:
  48.         regex = re.findall("href=\"(|\/\/|http(|s):\/\/)www\.elitepvpers\.com\/forum\/elite-gold-trading\/([0-9]+-(.+)){1}\.html\"", str(nya))
  49.         for poi in regex:
  50.             print("".join(poi)[1:] + "\n")
  51.  
  52.     output = open("output.html", "w")
  53.     output.write(str(posts))
  54.     output.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement