Created
August 6, 2018 08:26
-
-
Save tesths/0b9b4497ce057c3134a594088042c2a0 to your computer and use it in GitHub Desktop.
instagram story download
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
response = HTTParty.get('https://www.instagram.com/xx/', timeout: 60) | |
response = response.scan(/window._sharedData = (.*?);/)[0][0] | |
json = JSON.parse(response) | |
user_id = json['entry_data']['ProfilePage'][0]['graphql']['user']['id'] | |
puts user_id | |
url = 'https://i.instagram.com/api/v1/feed/user/' + user_id + '/reel_media/' | |
headers = { | |
'user-agent': 'Instagram 10.3.2 (iPhone7,2; iPhone OS 9_3_3; en_US; en-US; scale=2.00; 750x1334) AppleWebKit/420+', | |
'x-ig-capabilities': '36oD', | |
'cache-control': 'no-cache', | |
'cookie': '' | |
} | |
response = HTTParty.get(url, headers: headers) | |
story_json = JSON.parse(response.body) | |
puts response.body | |
for data in story_json['items'] | |
if data['media_type'] == 1 | |
puts data['image_versions2']['candidates'][0]['url'] | |
end | |
if data['media_type'] == 2 | |
puts data['video_versions'][0]['url'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment