Advertisement
DeaD_EyE

gehtslos.py

Jul 11th, 2024
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None | 0 0
  1. # Link zum Kanal: https://rumble.com/c/SC360Media
  2. # Das Programm sucht auf der Seite nach dem lezten Video
  3.  
  4.  
  5. import re
  6. import subprocess
  7.  
  8. from urllib.request import Request, urlopen, urljoin
  9.  
  10. # Externe Abhängigkeit
  11. from bs4 import BeautifulSoup
  12.  
  13.  
  14. def get_latest():
  15.     def _latest(a):
  16.         return int(re.search(r"\-(\d+)", a["href"]).group(1))
  17.  
  18.     base_url = "https://rumble.com"
  19.     headers = {
  20.         "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:126.0) Gecko/20100101 Firefox/126.0"
  21.     }
  22.  
  23.     doc = BeautifulSoup(
  24.         urlopen(
  25.             Request(
  26.                 urljoin(base_url, "c/SC360Media"),
  27.                 headers=headers,
  28.             )
  29.         ).read(),
  30.         "html.parser",
  31.     )
  32.     videos = [
  33.         a
  34.         for a in doc.find_all("a", attrs={"class": "videostream__link link"}, href=True)
  35.         if "gehts-los-folge" in a["href"]
  36.     ]
  37.     return urljoin(base_url, max(videos, key=_latest)["href"])
  38.  
  39.  
  40. print(get_latest())
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement