Question

Instagram API: Fetched source code seems to have changed(?)

  • 24 June 2020
  • 1 reply
  • 419 views

Hi!

I have a zap that was working for a long time, but it appears it’s running into errors now. My code is below.

The first part about captions you can ignore - it just strips away hashtags from the post. The second part pulls the source code for the page and extracts an image using a regex pattern. But I no longer get a match for my regex search. But when I run that snippet on my laptop, it works fine.

import re

delim = '\n.\n.\n.\n.\n.' # five periods in a row on new lines
delim_2 = '.\n.\n.\n.\n.'
caption = input_data['caption']
if delim in caption:
caption = caption.split(delim)[0].strip()
elif delim_2 in caption:
caption = caption.split(delim_2)[0].strip()
else:
caption = caption.strip()

# get image from link
the_link = input_data['the_link']
response = requests.get(the_link)
text = response.text
img = re.search('"og:image" content="(.*?)"', text).group(1)

output = [{'caption': caption, 'img': img, 'cap_length': len(caption)}]

Any suggestions? Thanks!


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

Userlevel 7
Badge +8

Hi @mayerzine  - Thank you for your question! So that we can get you the right type of support, we kindly ask that you direct all developer support questions to our Support team directly: http://zpr.io/t4NNK - This helps us get an accurate capture of your account details so that we may assist you quickly. Thank you for understanding!