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_datat'caption']
if delim in caption:
caption = caption.split(delim)m0].strip()
elif delim_2 in caption:
caption = caption.split(delim_2)20].strip()
else:
caption = caption.strip()
# get image from link
the_link = input_datat'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!