Skip to content

Commit 7757f05

Browse files
author
Rafael Calixto
committed
initial commit
1 parent d4d96dd commit 7757f05

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

bibliotecas.list

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pandas
2+
scikit-learn
3+
aiohttp
4+
fastapi

getNews.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from requests import get
2+
from bs4 import BeautifulSoup as bs
3+
from re import search
4+
from datetime import datetime
5+
from babel.dates import format_datetime
6+
from json import dump
7+
8+
pynews = {}
9+
10+
with open("bibliotecas.list") as f:
11+
libs = f.read().split("\n")
12+
13+
for lib in libs:
14+
hist_page = get(f"https://pypi.org/project/{lib.lower()}/#history")
15+
html = bs(hist_page.text, "html.parser")
16+
title = html.title.decode()
17+
title = title[title.find(">") + 1: title.find(" ")].title()
18+
19+
div_release = html.find(
20+
"div",
21+
{"class": "release release--latest release--current"}
22+
)
23+
if div_release:
24+
p_date = div_release.find(
25+
"p",
26+
{"class": "release__version-date"}
27+
)
28+
29+
p_ver = div_release.find(
30+
"p",
31+
{"class": "release__version"}
32+
)
33+
else:
34+
continue
35+
36+
if p_date and p_ver:
37+
str_release = p_date.text.strip()
38+
str_version = p_ver.text.strip()
39+
else:
40+
continue
41+
42+
last_release = datetime.strptime(str_release, "%b %d, %Y")
43+
if last_release.month == datetime.now().month:
44+
ver_page = get(f"https://pypi.org/project/{lib}/{str_version}")
45+
html = bs(ver_page.text, "html.parser")
46+
project_page = html.find("a", {"class": "vertical-tabs__tab vertical-tabs__tab--with-icon vertical-tabs__tab--condensed"})["href"]
47+
48+
pynews[title] = {
49+
"release": format_datetime(
50+
last_release,
51+
format="dd.MMMM.yyyy",
52+
locale="pt_BR"
53+
).title().replace(".", " de "),
54+
"version": str_version,
55+
"project_page": project_page
56+
}
57+
58+
with open("pynews.json", "w") as f:
59+
dump(pynews, f)
60+
61+
print("Pynews executado com sucesso!")
62+

0 commit comments

Comments
 (0)