kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.47k stars 635 forks source link

Error NotFound: Content Not Found in pages other than English #574

Closed elisa-mygit closed 3 years ago

elisa-mygit commented 3 years ago

Hi! When scraping for websites other than English, I get a NotFound error like this: (It doesn't happen for English sites)

NotFound                                  Traceback (most recent call last)
~/Desktop/fb/test.py in <module>
      375 from facebook_scraper import get_posts
----> 376 for post in get_posts('CowBaBanker', pages=1):
      377     print(post['text'][:100])

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/facebook_scraper/facebook_scraper.py in _generic_get_posts(self, extract_post_fn, iter_pages_fn, page_limit, options, remove_source, **kwargs)
    699 
    700         logger.debug("Starting to iterate pages")
--> 701         for i, page in zip(counter, iter_pages_fn()):
    702             logger.debug("Extracting posts from page %s", i)
    703             for post_element in page:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/facebook_scraper/page_iterators.py in generic_iter_pages(start_url, page_parser_cls, request_fn, **kwargs)
     61             try:
     62                 logger.debug("Requesting page from: %s", next_url)
---> 63                 response = request_fn(next_url)
     64                 break
     65             except HTTPError as e:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/facebook_scraper/facebook_scraper.py in get(self, url, **kwargs)
    589             if title:
    590                 if title.text.lower() in not_found_titles:
--> 591                     raise exceptions.NotFound(title.text)
    592                 elif title.text.lower() == "error":
    593                     raise exceptions.UnexpectedResponse("Your request couldn't be processed")

NotFound: Content Not Found

How can I resolve this issue? Thanks in advance for helping out in any case!! I really appreciate it!

neon-ninja commented 3 years ago

Try pass cookies as per the readme. This page isn't accessible unless you're logged in, which you can see if you go to https://m.facebook.com/CowBaBanker in an incognito window.

elisa-mygit commented 3 years ago

It's resolved now! Thank you so much!