Advertisement
Guest User

Untitled

a guest
Apr 12th, 2024
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. username = "your user name here"
  2. password = "your user password here"
  3.  
  4. # do not chnage anything below this line
  5. user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
  6. import requests
  7. import time
  8. from bs4 import BeautifulSoup
  9. session = requests.session()
  10. session.headers.update({"User-Agent": user_agent})
  11. login_page_url = "https://wallhaven.cc/login"
  12. login_page = session.get(login_page_url)
  13. login_soup = BeautifulSoup(login_page.text, "html.parser")
  14. login_token = login_soup.find("input", {"name": "_token"})["value"]
  15. login_data = {"_token": login_token, "username": username, "password": password}
  16. login_url = "https://wallhaven.cc/auth/login"
  17. login = session.post(login_url, data=login_data)
  18. subscription_url = "https://wallhaven.cc/subscription"
  19. subscription_page = session.get(subscription_url)
  20. subscription_soup = BeautifulSoup(subscription_page.text, "html.parser")
  21. tag_list = subscription_soup.find("h2", string="Tags").find_next_sibling(
  22.     "ul", class_="subscription-list"
  23. )
  24. subscriptions = tag_list.find_all("li")
  25. unsublist = []
  26. for sub in subscriptions:
  27.     sub_id = sub.find("a")["href"].split("/")[-1]
  28.     sub_name = sub.find("span", class_="tagname").text
  29.     unsub = input(f"Unsubscribe from {sub_name} (y/n)? ")
  30.     if unsub == "y":
  31.         unsublist.append({"sub_id": sub_id, "sub_name": sub_name})
  32. for unsub in unsublist:
  33.     unsub_url = f"https://wallhaven.cc/subscription/remove/tag/{unsub['sub_id']}?_token={login_token}"
  34.     unsub_page = session.get(unsub_url)
  35.     print(f"Unsubscribed from {unsub['sub_name']}")
  36.     time.sleep(1.7)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement