kevinzg / facebook-scraper

Scrape Facebook public pages without an API key
MIT License
2.33k stars 624 forks source link

'NoneType' object has no attribute 'attrs' using get_profile #776

Open p4rnicke opened 2 years ago

p4rnicke commented 2 years ago

profile = get_profile("tibiatya")

ERROR:facebook_scraper.extractors:'PostExtractor' object has no attribute 'post'

File "fbaccount.py", line 26, in do_GET profile = get_profile(pageName) File "appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages\facebook_scraper__init__.py", line 84, in get_profile return _scraper.get_profile(account, **kwargs) File "appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages\facebook_scraper\facebook_scraper.py", line 312, in get_profile ).extract_post_id()["post_id"] File "appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages\facebook_scraper\extractors.py", line 248, in extract_post_id or self.data_ft.get('top_level_post_id') File "appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages\facebook_scraper\extractors.py", line 1286, in data_ft data_ft_json = self.element.attrs['data-ft'].replace("\\", "\") AttributeError: 'NoneType' object has no attribute 'attrs'

neon-ninja commented 2 years ago

tibiatya is a Page, not a Profile. You should use get_page_info instead of get_profile

p4rnicke commented 2 years ago

Ok, I have changed it to get_page_info(pageName, cookies="from_browser"), but it says content not found. Do you have any suggestions?

File "\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages\jsonpickle\pickler.py", line 585, in _flatten_obj_instance data[tags.ITERATOR] = list(map(self._flatten, islice(obj, self._max_iter))) File "\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages\facebook_scraper\facebook_scraper.py", line 542, in get_page_reviews response = self.get(more_url) File "\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages\facebook_scraper\facebook_scraper.py", line 867, in get raise exceptions.NotFound(title.text) facebook_scraper.exceptions.NotFound: Content Not Found

neon-ninja commented 2 years ago

What pageName causes that exception?

p4rnicke commented 2 years ago

It is the same called "tibiatya" https://facebook.com/tibiatya

neon-ninja commented 2 years ago

I see - try https://github.com/kevinzg/facebook-scraper/commit/fb4e15eddeb48f80a028862a798222e00502d849, this should fix the problem