Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Малютин Дмитрий АТ-19 #46

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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_task.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'))

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

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


#Максимальное значение правок(58) также сходится с датой смерти актера - 6 сентября 2021 года.
14 changes: 14 additions & 0 deletions gradsky_task.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'))

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

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

#Максимальное значение правок(153) - 28 ноября 2021 года. В день смерти Александра Градского.
1 change: 1 addition & 0 deletions news.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions news_2.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions news_task_1.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 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)

14 changes: 14 additions & 0 deletions news_task_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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)

5 changes: 5 additions & 0 deletions report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
![](../../Downloads/2021-12-24_14-17-30.png)
![](../../Downloads/2021-12-24_14-16-55.png)
В обоих случаях дни с максимальным количеством правок совпали с датами смерти, но я считаю,
что для определения даты смерти опираться только на количество правок ненадежно, так как
большое количество правок может быть вызвано другим важным событием.