Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Belmondo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from itertools import groupby
from urllib.request import urlopen
from json import loads


url = 'https://ru.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&rvlimit=500&titles=%D0%91%D0%B5%D0' \
'%BB%D1%8C%D0%BC%D0%BE%D0%BD%D0%B4%D0%BE,_%D0%96%D0%B0%D0%BD-%D0%9F%D0%BE%D0%BB%D1%8C '
data = loads(urlopen(url).read().decode('utf8'))

groupby_data = groupby([i['timestamp'][:10] for i in data['query']['pages']['192203']['revisions']])

for date, edits in groupby_data:
print(date, len(list(edits)))

# 2021-09-06 58 - Бельмондо умер 2021-09-06
14 changes: 14 additions & 0 deletions Gradskiy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from itertools import groupby
from urllib.request import urlopen
from json import loads


url = 'https://ru.wikipedia.org/w/api.php?action=query&format=json&prop=revisions&rvlimit=500&titles=%D0%93%D1%80%D0%B0%D0%B4%D1%81%D0%BA%D0%B8%D0%B9,_%D0%90%D0%BB%D0%B5%D0%BA%D1%81%D0%B0%D0%BD%D0%B4%D1%80_%D0%91%D0%BE%D1%80%D0%B8%D1%81%D0%BE%D0%B2%D0%B8%D1%87'
data = loads(urlopen(url).read().decode('utf8'))

groupby_data = groupby([i['timestamp'][:10] for i in data['query']['pages']['183903']['revisions']])

for date, edits in groupby_data:
print(date, len(list(edits)))

# 2021-11-28 153 - больше всего правок (153) - Градский умер (2021-11-28)
1 change: 1 addition & 0 deletions news.json

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions news.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import xml.etree.ElementTree as ET
from urllib.request import urlopen
from json import dump

data = urlopen('https://lenta.ru/rss').read().decode('utf8')
root = ET.fromstring(data)
ans = []

for i in root.findall('channel/item'):
ans.append({'pubDate': i.find('pubDate').text,
'title': i.find('title').text})

with open("news.json", "w", encoding ='utf-8') as file:
dump(ans, file, ensure_ascii = False)


1 change: 1 addition & 0 deletions news_2.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions news_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import xml.etree.ElementTree as ET
from urllib.request import urlopen
from json import dump

data = urlopen('https://lenta.ru/rss').read().decode('utf8')
root = ET.fromstring(data)
ans = []

for item in root.findall('channel/item'):
ans.append({element.tag: element.text for element in item})

with open("news_2.json", "w", encoding ='utf-8') as file:
dump(ans, file, ensure_ascii = False)