Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- import requests
- from requests import session
- login_page = "http://forums.somethingawful.com/account.php?action=loginform#form"
- url = "http://forums.somethingawful.com/query.php?action=posthistory&userid=35304&page="
- USERNAME = ''
- PASSWORD = ''
- payload = {
- 'action': 'login',
- 'username': USERNAME,
- 'password': PASSWORD
- }
- """with session() as c:
- for x in range(1,101):
- c.post(login_page, data=payload)
- response = c.get(url+x)
- soup = BeautifulSoup(response.text, 'html.parser')
- mydivs = soup.findAll("div", {"class" : "blurb"})
- my_file = open("tori.txt", "a")
- for div in mydivs:
- my_file.write(div.string + "\n")
- my_file.close() """
- with session() as c:
- c.post(login_page, data = payload)
- for x in range(1,101):
- response = c.get(url + str(x))
- soup = BeautifulSoup(response.text, 'html.parser')
- mydivs = soup.findAll("div", {"class" : "blurb"})
- my_file = open("tori.txt", "a")
- my_file.write("\n" + "\n" + "\n" + "\n" + "Page number: " + str(x) + "\n" + "\n" + "\n" + "\n")
- for div in mydivs:
- if "[quote=" not in div.string:
- my_file.write(div.string + "\n")
- else:
- my_file.write("\n")
- my_file.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement