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 #42

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


def get_day(revision):
timestamp = revision['timestamp']
return datetime.datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%SZ').date()



def get_revisions(id, url):
data = json.loads(urlopen(url).read().decode('utf-8'))
revisions = data['query']['pages'][str(id)]['revisions']
for key, group_items in groupby(revisions, key=get_day):
print(key, sum(1 for i in group_items))


pade_id_grad = 183903
url_grad = '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'
# get_revisions(pade_id_grad, url_grad)

page_id_bel = 192203
url_bel = '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'
get_revisions(page_id_bel, url_bel)
1 change: 1 addition & 0 deletions news.json

Large diffs are not rendered by default.

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



data = urlopen('https://lenta.ru/rss').read().decode("utf-8")
root = Et.fromstring(data)
channel = root[0]
allNews = []

def get_news():
for i in channel.findall("item"):
allNews.append({'pubDate': i.find('pubDate').text, 'title': i.find('title').text})
return allNews


result = json.dumps(get_news(), ensure_ascii=False).encode('utf-8')
with open('news.json', 'wb') as f:
f.write(result)

# rework for task2

allNews2 = []
def get_news_new():
for i in channel.findall("item"):
fields = {}
for field in i:
fields[field.tag] = field.text
allNews2.append(fields)
return allNews2


result = json.dumps(get_news_new(), ensure_ascii=False).encode('utf-8')
with open('news2.json', 'wb') as f:
f.write(result)



1 change: 1 addition & 0 deletions news2.json

Large diffs are not rendered by default.

141 changes: 141 additions & 0 deletions res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
Больше всего правок пришлось на 28.11.2021, что и является смертью певца

2021-12-16 1
2021-12-15 3
2021-12-14 2
2021-12-11 1
2021-12-09 3
2021-12-08 2
2021-12-07 2
2021-12-06 5
2021-12-05 1
2021-12-04 10
2021-12-03 12
2021-12-02 23
2021-11-29 16
2021-11-28 153
2021-11-27 5
2021-11-26 9
2021-11-24 1
2021-11-16 1
2021-11-15 2
2021-11-14 1
2021-11-11 1
2021-10-17 2
2021-10-10 3
2021-09-25 2
2021-09-24 1
2021-09-17 2
2021-09-01 1
2021-08-27 2
2021-08-23 3
2021-08-18 1
2021-07-16 2
2021-06-08 1
2021-06-03 1
2021-04-28 1
2021-03-25 3
2021-02-06 2
2021-01-31 1
2020-12-29 1
2020-12-28 1
2020-11-27 2
2020-10-30 2
2020-10-29 2
2020-10-24 4
2020-10-21 3
2020-10-15 3
2020-10-06 1
2020-09-29 1
2020-07-31 2
2020-07-30 1
2020-07-08 2
2020-06-05 2
2020-05-18 2
2020-04-12 2
2020-04-11 1
2020-04-10 2
2020-03-24 2
2020-02-18 3
2020-01-16 1
2019-12-04 4
2019-11-23 6
2019-11-19 1
2019-11-15 1
2019-11-11 2
2019-11-10 1
2019-11-09 1
2019-11-08 2
2019-11-06 4
2019-11-03 3
2019-10-30 7
2019-10-19 1
2019-08-14 1
2019-08-07 1
2019-07-26 1
2019-05-23 2
2019-05-20 1
2019-04-02 2
2019-02-27 2
2019-02-26 1
2019-02-18 1
2019-02-15 1
2019-01-27 1
2019-01-21 4
2019-01-12 4
2018-12-23 5
2018-12-22 7
2018-12-14 2
2018-11-09 2
2018-11-03 1
2018-11-01 4
2018-10-26 1
2018-09-19 5
2018-09-15 1
2018-09-07 3
2018-08-15 1
2018-08-11 4
2018-08-05 3
2018-07-23 2
2018-06-30 4
2018-06-15 1
2018-05-16 1
2018-04-06 1
2018-04-04 1
2018-04-02 1
2018-02-18 1
2018-01-13 1
2018-01-04 3
2018-01-03 2
2017-12-30 1
2017-12-20 2
2017-12-19 2
2017-12-02 1
2017-11-27 4
2017-11-10 2
2017-11-08 1
2017-10-25 1
2017-10-09 1
2017-10-03 1
2017-09-29 1
2017-09-23 2
2017-09-15 1
2017-09-14 2
2017-09-08 1
2017-08-21 2
2017-08-14 4
2017-08-02 1
2017-06-30 1
2017-06-29 1
2017-06-25 3
2017-06-04 3
2017-05-28 1
2017-05-16 1
2017-05-14 2
2017-05-06 2
2017-04-18 1
2017-03-26 1
2017-03-09 1
2017-03-01 1
2017-02-23 1

Loading