回答編集履歴
1
test
CHANGED
@@ -2,14 +2,18 @@
|
|
2
2
|
|
3
3
|
```python
|
4
4
|
import requests
|
5
|
+
import sys
|
5
6
|
|
6
7
|
url = "https://t.co/oTzl0VGefO"
|
8
|
+
r = requests.head(url)
|
9
|
+
if 'Location' in r.headers:
|
7
|
-
afp_url = 'http://
|
10
|
+
afp_url = r.headers['Location'].replace('https://', 'http://')
|
11
|
+
else:
|
12
|
+
sys.exit(1)
|
13
|
+
|
8
14
|
headers = { 'Referer': url }
|
9
|
-
|
10
15
|
r = requests.head(afp_url, headers=headers)
|
11
16
|
print(r.headers['Location'])
|
12
17
|
|
13
|
-
#
|
14
18
|
# https://www.barrons.com/news/putin-says-russia-could-leave-grain-deal-again-if-ukraine-violates-guarantees-01667400007
|
15
19
|
```
|