generated from github/haikus-for-codespaces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_6_3.py
29 lines (24 loc) · 1.22 KB
/
3_6_3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
'''
Имеется набор файлов, каждый из которых, кроме последнего, содержит имя следующего файла.
Первое слово в тексте последнего файла: "We".
Скачайте предложенный файл. В нём содержится ссылка на первый файл из этого набора.
Все файлы располагаются в каталоге по адресу:
https://stepic.org/media/attachments/course67/3.6.3/
Загрузите содержимое последнего файла из набора, как ответ на это задание.
'''
import requests
with open('/Users/vitalyskiba/Downloads/dataset_3378_3.txt') as inf:
s = inf.read().strip().split()
r = requests.get(s[0])
print(r.text) # содерит ИМЯ в виде конца ссылки вида урл/ + ИМЯ
while not r.text.startswith('We'):
r = requests.get('https://stepik.org/media/attachments/course67/3.6.3/' + r.text)
print(r.text)
'''
We are the champions, my friends,
And we'll keep on fighting 'til the end.
We are the champions.
We are the champions.
No time for losers
'Cause we are the champions of the world.
'''