Skip to content

Commit 37373dc

Browse files
committed
chore: remove deprecated robobrowser, werkzeug and markupsafe dependencies and replace with requests + bs4
1 parent 7f4e7b9 commit 37373dc

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

conciertos.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
from datetime import datetime
44
from dataclasses import dataclass
5-
from robobrowser import RoboBrowser
5+
import requests
6+
from bs4 import BeautifulSoup
67

78
@dataclass
89
class Concierto:
@@ -26,13 +27,13 @@ def parse(evento):
2627
return None
2728

2829
def fetch_conciertos():
29-
browser = RoboBrowser(parser="html.parser")
30-
31-
browser.open("https://www.songkick.com/venues/4514007-estadio-river-plate/calendar")
30+
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'}
31+
res = requests.get("https://www.songkick.com/venues/4514007-estadio-river-plate/calendar", headers=headers)
32+
soup = BeautifulSoup(res.text, "html.parser")
3233

3334
conciertos = []
3435

35-
for el in browser.select(".microformat"):
36+
for el in soup.select(".microformat"):
3637
concierto = Concierto.parse(el)
3738
if concierto:
3839
conciertos.append(concierto)

requirements.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ icalevents
22
pytz
33
requests
44
python-telegram-bot[webhooks]==22.0
5-
robobrowser==0.5.3
6-
Werkzeug==0.15.5
7-
MarkupSafe==2.0.1
5+
beautifulsoup4
86
psycopg2-binary
97
SQLAlchemy
108
sqlalchemy-cockroachdb

river.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from datetime import datetime
22
from dataclasses import dataclass
3-
from robobrowser import RoboBrowser
3+
import requests
4+
from bs4 import BeautifulSoup
45

56
RIVER = "River Plate"
67
UNSPECIFIED_TIMES = {"A confirmar", ""}
@@ -50,13 +51,17 @@ def parse(el):
5051
)
5152

5253
def fetch_partidos():
53-
browser = RoboBrowser(parser="html.parser")
54-
browser.open("https://www.cariverplate.com.ar/calendario-de-partidos")
54+
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)'}
55+
res = requests.get("https://www.cariverplate.com.ar/calendario-de-partidos", headers=headers)
56+
soup = BeautifulSoup(res.text, "html.parser")
5557

5658
partidos = []
5759

58-
for el in browser.select(".d_calendario"):
59-
partidos.append(Partido.parse(el))
60+
for el in soup.select(".d_calendario"):
61+
try:
62+
partidos.append(Partido.parse(el))
63+
except ValueError:
64+
pass
6065

6166
return partidos
6267

0 commit comments

Comments
 (0)