Skip to content
This repository has been archived by the owner on Apr 24, 2021. It is now read-only.

Commit

Permalink
🐛 Fixed bug for not downloading single image posts
Browse files Browse the repository at this point in the history
  • Loading branch information
Stef committed Jun 22, 2020
1 parent b5fc4da commit 30d1943
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,27 @@ def download_img(html_doc,username):
img_list = []
json_data = re.search('window._sharedData = (.*);</script>',html_doc).group(1)
d = json.loads(json_data)
global image_counter
co =0
while True:
try:
img_list.append(d["entry_data"]["PostPage"][0]["graphql"]["shortcode_media"]["edge_sidecar_to_children"]["edges"][co]["node"]["display_url"])
co+=1
except:
break
for link in img_list:
if not img_list:
result = re.search('"og:image" content="(.*)"', html_doc)
link = result.group(1)
logging.info('Downloading Image')
name=wget.download(link,'POSTS/'+username+'/')
logging.info("\n"+name)
global image_counter
image_counter += 1
else:
for link in img_list:
logging.info('Downloading Image')
name=wget.download(link,'POSTS/'+username+'/')
logging.info("\n"+name)
image_counter += 1

def get_end_cursor(uid):
url = "https://www.instagram.com/p/"+str(uid)
Expand Down

0 comments on commit 30d1943

Please # to comment.