diff --git a/serverPython/facebook_bot.py b/serverPython/facebook_bot.py index 8777c63..daeb150 100644 --- a/serverPython/facebook_bot.py +++ b/serverPython/facebook_bot.py @@ -85,16 +85,26 @@ class FacebookBot: if current_post_count == post_index: comment_btn = btn break - else: logging.info(f"Đã thấy bài viết thứ {current_post_count}, đang đẩy nó vào góc khuất để tìm bài {post_index}...") bounds = btn.info["bounds"] - center_x = (bounds["left"] + bounds["right"]) // 2 start_y = bounds["bottom"] - # Vuốt đúng khoảng cách để đẩy nút Bình luận hiện tại lên tọa độ Y=200 (Vùng bị bỏ qua) - if start_y > 250: - self.d.swipe(center_x, start_y, center_x, 200, duration=0.4) - time.sleep(2) + # Tính tổng quãng đường cần vuốt để đẩy nút này lên tọa độ Y=200 + distance_needed = start_y - 200 + + if distance_needed > 0: + screen_width = self.d.info['displayWidth'] + mid_x = screen_width // 2 + + # Cắt nhỏ quãng đường vuốt (tối đa 1000px mỗi cú) và vuốt từ GIỮA màn hình + # để tránh vuốt nhầm vào thanh điều hướng ở mép dưới hoặc mép trên. + while distance_needed > 0: + swipe_dist = min(distance_needed, 1000) + self.d.swipe(mid_x, 1500, mid_x, 1500 - swipe_dist, duration=0.3) + time.sleep(1) + distance_needed -= swipe_dist + + time.sleep(1) # Nghỉ một nhịp sau khi vuốt xong current_post_count += 1 continue