# -*- coding: utf-8 -*- # # Copyright(c) 2015 http://feilong.me # # @author: Felinx Lee # from tornado.httpclient import HTTPClient, HTTPRequest from tornado import escape import hashlib cookie = "csrftoken=..." # Your current cookie cookie = escape.squeeze(cookie) agent = "Instagram 6.14.0 (iPhone7,1; iPhone OS 8_3; zh_CN;zh-Hans) AppleWebKit/420+" url = "https://i.instagram.com/api/v1/feed/user/USER_ID" # USER_ID should be replaced by real ID like 12345678 def main(): client = HTTPClient() request = HTTPRequest(url, headers={"Cookie": cookie, "User-Agent": agent}) response = client.fetch(request) resp = escape.json_decode(response.body) items = resp.get("items", []) for item in items: imgurl = item["image_versions2"]["candidates"][0]["url"] urlmd5 = hashlib.md5(imgurl).hexdigest() print "wget '%s' -O %s.jpg" % (imgurl, urlmd5) # or run this command in Python or request img file again if __name__ == '__main__': main()