Уведомления

Группа в Telegram: @pythonsu

#1 Окт. 18, 2017 21:22:45

beren43
Зарегистрирован: 2017-10-18
Сообщения: 3
Репутация: +  0  -
Профиль   Отправить e-mail  

Json


Здравствуйте.
Решаю тренеровочную задачу:
Вывести на экран данные по заблокированным ресурсам за период с 25.03.2014 по 30.03.2014 с https://antizapret.info/ в формате:
ip1 > domain
ip2 > domain
Почитавши, https://antizapret.info/api.php можно использовать https://api.antizapret.info/diff.php…3-30&type=json
Вот до чего пока дошёл я

 import urllib.request
import urllib.parse
import json
doc = urllib.request.urlopen("https://api.antizapret.info/diff.php?dateStart=2014-03-25&dateCurrent=2014-03-30&type=json")
data = doc.read()
encoding = doc.info().get_content_charset('utf-8')
Объясните,пожалуйста, что происходит тут
 data = doc.read()
encoding = doc.info().get_content_charset('utf-8')
А в целом, готовый код не нужен. Нужны советы как можно реализовать.
Спасибо.

Офлайн

#2 Окт. 19, 2017 06:46:35

FishHook
От:
Зарегистрирован: 2011-01-08
Сообщения: 8312
Репутация: +  568  -
Профиль   Отправить e-mail  

Json

The info() method returns an instance of the class mimetools.Message containing meta-information associated with the URL. When the method is HTTP, these headers are those returned by the server at the head of the retrieved HTML page (including Content-Length and Content-Type). When the method is FTP, a Content-Length header will be present if (as is now usual) the server passed back a file length in response to the FTP retrieval request. A Content-Type header will be present if the MIME type can be guessed. When the method is local-file, returned headers will include a Date representing the file’s last-modified time, a Content-Length giving file size, and a Content-Type containing a guess at the file’s type. See also the description of the mimetools module.



Офлайн

#3 Окт. 19, 2017 20:42:52

beren43
Зарегистрирован: 2017-10-18
Сообщения: 3
Репутация: +  0  -
Профиль   Отправить e-mail  

Json

Спасибо. Есть идеи, как дальше делать ?

Офлайн

#4 Окт. 19, 2017 21:29:16

beren43
Зарегистрирован: 2017-10-18
Сообщения: 3
Репутация: +  0  -
Профиль   Отправить e-mail  

Json

Появилась идея

 ip  = i.get("recordsAdded")[0].get ("ip")

Но как вывести с первого по последний ip ?

Офлайн

Board footer

Модераторировать

Powered by DjangoBB

Lo-Fi Version