facebook_page_scraper icon indicating copy to clipboard operation
facebook_page_scraper copied to clipboard

No posts were found!

Open abigmeh opened this issue 2 years ago • 9 comments

Hey! Thanks for your script. But I was trying to run your example and get the 'no posts were found' error. Is it because of the new layout? Thanks!

abigmeh avatar Mar 03 '22 16:03 abigmeh

Hi, Can you share what page were you trying to scrape?. I am unable to reproduce this issue

shaikhsajid1111 avatar Mar 05 '22 04:03 shaikhsajid1111

Hey, I am just using your example code which is 'facebookai'. Mmmm then this is weird Maybe because I used Chrome instead of Firefox?

abigmeh avatar Mar 05 '22 10:03 abigmeh

It can vary with

  • Geographical location as some countries have strict privacy policies. For example countries like Germany, France has very strict policies, you can't open FB pages without authentication whereas in countries located in South Asia Like India where you can easily access them.
  • If you've tried scraping FB too much then even you get redirected to the login page which will throw this error.
  • Improper synchronization like your machine is lagging that also won't load browser properly which will affect bot to scrape.

I think you're probably hitting authentication wall which is creating this issue.

shaikhsajid1111 avatar Mar 05 '22 10:03 shaikhsajid1111

This is a new M1 chip laptop which has never been used for scaping FB data before, could be because I am in Spain, that's why. Thanks for the info!

abigmeh avatar Mar 05 '22 18:03 abigmeh

@abigmeh I apologize but you've tried 'facebookai'. Right? but it does not exist anymore, I forgot to update that code part of the document. It should be 'MetaAI', not 'facebookai' . I totally forget about this

shaikhsajid1111 avatar Mar 06 '22 04:03 shaikhsajid1111

Oh, it's ok, it will be directed to 'metaAi' anyway, and I also tested other pages like 'pepsi'. I think I will try to modify the proxy settings, let's see hahahaha.

abigmeh avatar Mar 06 '22 10:03 abigmeh

Okay 😅

shaikhsajid1111 avatar Mar 06 '22 13:03 shaikhsajid1111

I received the error stated below when I ran it.

[WDM] - Current google-chrome version is 104.0.5112 [WDM] - Get LATEST driver version for 104.0.5112 Using: IP:PORT

[WDM] - Driver [C:\Users\Pc.wdm\drivers\chromedriver\win32\104.0.5112.79\chromedriver.exe] found in cache No posts were found!

TimeoutException Traceback (most recent call last) File ~\anaconda3\lib\site-packages\facebook_page_scraper\driver_utilities.py:119, in Utilities.__wait_for_element_to_appear(driver, layout) 118 elif layout == "new": --> 119 WebDriverWait(driver, 30).until( 120 EC.presence_of_element_located((By.CSS_SELECTOR, "[aria-posinset]"))) 122 except WebDriverException: 123 #if it was not found,it means either page is not loading or it does not exists

File ~\anaconda3\lib\site-packages\selenium\webdriver\support\wait.py:89, in WebDriverWait.until(self, method, message) 88 break ---> 89 raise TimeoutException(message, screen, stacktrace)

TimeoutException: Message: Stacktrace: Backtrace: Ordinal0 [0x00DE78B3+2193587] Ordinal0 [0x00D80681+1771137] Ordinal0 [0x00C941A8+803240] Ordinal0 [0x00CC24A0+992416] Ordinal0 [0x00CC273B+993083] Ordinal0 [0x00CEF7C2+1177538] Ordinal0 [0x00CDD7F4+1103860] Ordinal0 [0x00CEDAE2+1170146] Ordinal0 [0x00CDD5C6+1103302] Ordinal0 [0x00CB77E0+948192] Ordinal0 [0x00CB86E6+952038] GetHandleVerifier [0x01090CB2+2738370] GetHandleVerifier [0x010821B8+2678216] GetHandleVerifier [0x00E717AA+512954] GetHandleVerifier [0x00E70856+509030] Ordinal0 [0x00D8743B+1799227] Ordinal0 [0x00D8BB68+1817448] Ordinal0 [0x00D8BC55+1817685] Ordinal0 [0x00D95230+1856048] BaseThreadInitThunk [0x74CA62C4+36] RtlSubscribeWnfStateChangeNotification [0x778C0FD9+1081] RtlSubscribeWnfStateChangeNotification [0x778C0FA4+1028]

During handling of the above exception, another exception occurred:

SystemExit Traceback (most recent call last) [... skipping hidden 1 frame]

Input In [12], in <cell line: 3>() 1 #call the scrap_to_json() method ----> 3 json_data = meta_ai.scrap_to_json() 4 print(json_data)

File ~\anaconda3\lib\site-packages\facebook_page_scraper\scraper.py:84, in Facebook_scraper.scrap_to_json(self) 83 #wait for post to load ---> 84 Utilities._Utilities__wait_for_element_to_appear(self.__driver,self.__layout) 85 #scroll down to bottom most

File ~\anaconda3\lib\site-packages\facebook_page_scraper\driver_utilities.py:126, in Utilities.__wait_for_element_to_appear(driver, layout) 125 Utilities.__close_driver(driver) --> 126 sys.exit(1) #exit the program, because if posts does not exists,we cannot go further 127 except Exception as ex:

SystemExit: 1

During handling of the above exception, another exception occurred:

AssertionError Traceback (most recent call last) [... skipping hidden 1 frame]

File ~\anaconda3\lib\site-packages\IPython\core\interactiveshell.py:1972, in InteractiveShell.showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code) 1969 if exception_only: 1970 stb = ['An exception has occurred, use %tb to see ' 1971 'the full traceback.\n'] -> 1972 stb.extend(self.InteractiveTB.get_exception_only(etype, 1973 value)) 1974 else: 1975 try: 1976 # Exception classes can customise their traceback - we 1977 # use this in IPython.parallel for exceptions occurring 1978 # in the engines. This should return a list of strings.

File ~\anaconda3\lib\site-packages\IPython\core\ultratb.py:585, in ListTB.get_exception_only(self, etype, value) 577 def get_exception_only(self, etype, value): 578 """Only print the exception type and message, without a traceback. 579 580 Parameters (...) 583 value : exception value 584 """ --> 585 return ListTB.structured_traceback(self, etype, value)

File ~\anaconda3\lib\site-packages\IPython\core\ultratb.py:443, in ListTB.structured_traceback(self, etype, evalue, etb, tb_offset, context) 440 chained_exc_ids.add(id(exception[1])) 441 chained_exceptions_tb_offset = 0 442 out_list = ( --> 443 self.structured_traceback( 444 etype, evalue, (etb, chained_exc_ids), 445 chained_exceptions_tb_offset, context) 446 + chained_exception_message 447 + out_list) 449 return out_list

File ~\anaconda3\lib\site-packages\IPython\core\ultratb.py:1118, in AutoFormattedTB.structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context) 1116 else: 1117 self.tb = tb -> 1118 return FormattedTB.structured_traceback( 1119 self, etype, value, tb, tb_offset, number_of_lines_of_context)

File ~\anaconda3\lib\site-packages\IPython\core\ultratb.py:1012, in FormattedTB.structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context) 1009 mode = self.mode 1010 if mode in self.verbose_modes: 1011 # Verbose modes need a full traceback -> 1012 return VerboseTB.structured_traceback( 1013 self, etype, value, tb, tb_offset, number_of_lines_of_context 1014 ) 1015 elif mode == 'Minimal': 1016 return ListTB.get_exception_only(self, etype, value)

File ~\anaconda3\lib\site-packages\IPython\core\ultratb.py:865, in VerboseTB.structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context) 856 def structured_traceback( 857 self, 858 etype: type, (...) 862 number_of_lines_of_context: int = 5, 863 ): 864 """Return a nice text document describing the traceback.""" --> 865 formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context, 866 tb_offset) 868 colors = self.Colors # just a shorthand + quicker name lookup 869 colorsnormal = colors.Normal # used a lot

File ~\anaconda3\lib\site-packages\IPython\core\ultratb.py:799, in VerboseTB.format_exception_as_a_whole(self, etype, evalue, etb, number_of_lines_of_context, tb_offset) 796 assert isinstance(tb_offset, int) 797 head = self.prepare_header(etype, self.long_header) 798 records = ( --> 799 self.get_records(etb, number_of_lines_of_context, tb_offset) if etb else [] 800 ) 802 frames = [] 803 skipped = 0

File ~\anaconda3\lib\site-packages\IPython\core\ultratb.py:854, in VerboseTB.get_records(self, etb, number_of_lines_of_context, tb_offset) 848 formatter = None 849 options = stack_data.Options( 850 before=before, 851 after=after, 852 pygments_formatter=formatter, 853 ) --> 854 return list(stack_data.FrameInfo.stack_data(etb, options=options))[tb_offset:]

File ~\anaconda3\lib\site-packages\stack_data\core.py:546, in FrameInfo.stack_data(cls, frame_or_tb, options, collapse_repeated_frames) 530 @classmethod 531 def stack_data( 532 cls, (...) 536 collapse_repeated_frames: bool = True 537 ) -> Iterator[Union['FrameInfo', RepeatedFrames]]: 538 """ 539 An iterator of FrameInfo and RepeatedFrames objects representing 540 a full traceback or stack. Similar consecutive frames are collapsed into RepeatedFrames (...) 544 and optionally an Options object to configure. 545 """ --> 546 stack = list(iter_stack(frame_or_tb)) 548 # Reverse the stack from a frame so that it's in the same order 549 # as the order from a traceback, which is the order of a printed 550 # traceback when read top to bottom (most recent call last) 551 if is_frame(frame_or_tb):

File ~\anaconda3\lib\site-packages\stack_data\utils.py:98, in iter_stack(frame_or_tb) 96 while frame_or_tb: 97 yield frame_or_tb ---> 98 if is_frame(frame_or_tb): 99 frame_or_tb = frame_or_tb.f_back 100 else:

File ~\anaconda3\lib\site-packages\stack_data\utils.py:91, in is_frame(frame_or_tb) 90 def is_frame(frame_or_tb: Union[FrameType, TracebackType]) -> bool: ---> 91 assert_(isinstance(frame_or_tb, (types.FrameType, types.TracebackType))) 92 return isinstance(frame_or_tb, (types.FrameType,))

File ~\anaconda3\lib\site-packages\stack_data\utils.py:172, in assert_(condition, error) 170 if isinstance(error, str): 171 error = AssertionError(error) --> 172 raise error

AssertionError:

Laju11 avatar Aug 14 '22 09:08 Laju11

@Laju11 Please share the code that you tried and the environment that you're using

shaikhsajid1111 avatar Aug 14 '22 09:08 shaikhsajid1111