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

Igor Koryakin AT-18 #39

Open
wants to merge 2 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
11 changes: 11 additions & 0 deletions API-Belm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from urllib.request import urlopen
from json import loads
from itertools import groupby

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'))
id = '192203'

group_data = groupby([i['timestamp'][:10] for i in data['query']['pages'][id]['revisions']])
for e, edit in group_data:
print(e, len(list(edit)))
11 changes: 11 additions & 0 deletions API-Grad.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from urllib.request import urlopen
from json import loads
from itertools import groupby

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'))
id = "183903"

group_data = groupby([i['timestamp'][:10] for i in data['query']['pages'][id]['revisions']])
for e, edit in group_data:
print(e, len(list(edit)))
12 changes: 12 additions & 0 deletions LentaNews.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from json import dump
import xml.etree.ElementTree as ET
from urllib.request import urlopen

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

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

with open("lenta_news.json", "w", encoding='UTF-8') as file:
dump(news_list, file, indent=1, ensure_ascii=False)
16 changes: 16 additions & 0 deletions REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# API

Градский

![Grad_date](https://github.com/Roggi7/xmljson/blob/main/grad_date.png)

Самая частая дата запросов по результатам правок - 28 ноября 2021 года.

Бельмодно

![Belm_date](https://github.com/Roggi7/xmljson/blob/main/belm-date.png)

Самая частая дата запросов по результатам правок - 6 сентября 2021 года. Действительно, обе эти даты сходятся с датами
смерти актёров, чем может быть объяснена такая популярность запросов по ним. Однако такая метрика достаточно ненадёжна,
поскольку в эти дни могли происходить и другие события связанные с этими людьми: день рождения, памятная дата, участие
в крупных проектах.
Binary file added belm-date.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added grad_date.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading