0

I wish to scrape photo links from a facebook's html code. It is given as:

<img class="_7jys img" src="https://scontent-arn2-2.xx.fbcdn.net/v/t39.16868-6/s600x600/70767091_398966137483846_5448404540279750656_n.jpg?_ncx" alt="">

I am trying to do:

url = 'https://www.facebook.com/ads/archive/render_ad/?'

response = requests.get(url, timeout=5)
content = BeautifulSoup(response.content, "html.parser")

garbage = []

for item in content.findAll('src', attrs={'class': 'img' }):
    print(item)
    garbage.append(item.text)

It returns an empty list. How do I access the tag?

SIM
  • 21,997
  • 5
  • 37
  • 109
JOKKINATOR
  • 356
  • 1
  • 11
  • [Is scraping from public Facebook pages legal?](https://stackoverflow.com/q/38772604/215552)... – Heretic Monkey Oct 09 '19 at 18:12
  • See this article https://stackoverflow.com/questions/43982002/extract-src-attribute-from-img-tag-using-beautifulsoup/47166671 – Soren Oct 09 '19 at 18:24
  • To add to the previous comments, it's likely you're hitting one of Facebook's security mechanisms that's in place to prevent this activity (which, to re-iterate, is a violation of their Terms of Service). – esqew Oct 09 '19 at 19:33

0 Answers0