Facebook_scraper exceptions temporarilybanned youre temporarily blocked
Ngày đăng:
26/11/2022
Trả lời:
0
Lượt xem:
82
See below my method for scraping groups including comments and replies using the latest master. Scraping 100 posts including comments and replies takes ~ 10 minutes with this configuration. After 100 posts I am getting Any suggestions? I feel the delays are very high already. def scrape_group_posts(self, group_ids: List[Union[int, str]]): def handle_pagination_url(url): nonlocal start_url start_url = url for k, group_id in enumerate(group_ids, 1): group_name = self.group_information[group_id]['name'] log.info(f"[{k}] Scraping group: {group_name}...") start_url = None post_counter = 0 keep_alive = True while keep_alive: try: posts = self.get_group_posts( group=group_id, options={ "comments": "generator" if config.SCRAPE_COMMENTS else False, "comment_start_url": start_url, "comment_request_url_callback": handle_pagination_url } ) while post := next(posts, None): post_counter += 1 if post["time"] < config.DATELIMIT: log.info(f"[{group_name}] Reached datelimit: {config.DATELIMIT}") keep_alive = False break log.info(f"[{group_name}] Scraping post {post_counter} from {str(post['time'])[:19]}...") for item in ('post_text', 'shared_text', 'text'): comments = post['comments_full'] # It is possible, that comments are of type list if type(comments) == iter: comment_counter = 0 while comment := next(comments, None): comment_counter += 1 log.info(f"[{group_name}] Scraping comment {comment_counter} from {str(comment['comment_time'])[:19]} to post {post_counter}...") replies = comment['replies'] if type(replies) == iter: replies_counter = 0 while reply := next(replies, None): replies_counter += 1 log.info(f"[{group_name}] Scraping reply {replies_counter} from {str(reply['comment_time'])[:19]} to comment {comment_counter} of post {post_counter}...") random_sleep((3, 3.5), (4, 5), reason=f"{group_name}|WAIT_BEFORE_NEXT_REPLY") elif type(replies) == list and replies: log.warning(f"Found non-empty comment-replies as list ->\n{format_json(replies)}") random_sleep((3, 3.5), (4, 5), reason=f"{group_name}|WAIT_BEFORE_NEXT_COMMENT") elif type(comments) == list and comments: log.warning(f"Found non-empty comments as list ->\n{format_json(comments)}") random_sleep((3, 3.5), (4, 5), reason=f"{group_name}|WAIT_BEFORE_NEXT_POST") # We reach this without exception, then we have completed scraping this group keep_alive = False except TemporarilyBanned as e: random_sleep((580, 590), (600, 610), reason=f"{group_name}|{e.__class__.__name__}") Why is Facebook temporarily blocking me?We may block people from doing something on Facebook when: Something you posted or shared seems suspicious or abusive to our security systems. Messages or friend requests you sent were marked unwelcome. You've done something that doesn't follow our Community Standards.
Why does Facebook block me for scrolling too fast?A number of people have had this happen to them according to an online search. Apparently, any activities done repeatedly in quick succession get flagged. Facebook AI thinks you are a spammer or a robot. Because a robot is trying to determine if you are human or not. Other people online seem to have had the same issue.
|