Advertisement
furas

Python - facebook AdSet - indentions

Mar 1st, 2017
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. account = AdAccount('act_xxxxxxxxxxxxx')
  2. ads = account.get_ads(fields=[Ad.Field.id])
  3. for id in ads:
  4.     ad = Ad(id["id"])
  5.     ad_preview = ad.get_previews(params={'ad_format': AdPreview.AdFormat.desktop_feed_standard,})
  6.     # you need bigger indentions - second "for" has to be inside first "for"
  7.     for pre in ad_preview:
  8.         preview = pre["body"]
  9.         # preview = str(preview) # preview should be string so you don't need str()
  10.         preview = preview.replace("amp;", "")
  11.         preview = preview.split('src="')[1].split('" width')[0] # you don't need external ()
  12.         print preview
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement