-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
83 lines (48 loc) · 1.4 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
# coding: utf-8
# In[1]:
from bs4 import BeautifulSoup as bs
import requests as req
# https://github.com/egorsmkv/rfeed
from feedgen.feed import FeedGenerator
# In[2]:
RUMBLE_URL = "https://rumble.com/c/"
USERNAME = ""
URL = f"{RUMBLE_URL}{USERNAME}"
PAGES = 15
# In[3]:
pages = []
for n in range(0, PAGES):
if USERNAME == "": # Putting this here to avoid ipython issues
break
page_raw = req.get(f"{URL}?page={n}")
page_soup = bs(page_raw.content, 'html.parser')
if page_soup.h1.text == "404 - Not found":
break
pages.append(page_soup.find_all("article"))
# In[4]:
data_dict = []
for article_page in pages:
for article in article_page:
data_dict.append({
'title': article.h3.text,
'date': article.time["datetime"],
'duration': article.span["data-value"],
'URL': article.a["href"]
})
# In[5]:
feed = FeedGenerator()
feed.id(URL)
feed.title(f" {USERNAME} ")
feed.link(rel="self", href=URL)
feed.description(f" {USERNAME} ") # Requires a description but none given on Rumble
for item in data_dict:
entry = feed.add_entry()
entry.id(item['URL'])
entry.title(item["title"])
entry.pubDate(item["date"])
entry.description(item["duration"])
entry.link(href=item['URL'])
# In[6]:
#feed.rss_str(pretty=True)
feed.rss_file(f"{USERNAME}_feed.rss")