赞
踩
import pyautogui import time from PIL import Image def capture_screenshot(page_number): screenshot = pyautogui.screenshot(region=(0,0,821,1090))# 定义截图区域,左上角x,y,右下角x,y screenshot.save(f'wechat_chat_page_{page_number}.png') print(f'Captured chat page {page_number}') def scroll_chat(): # Adjust the scrolling distance and speed as needed pyautogui.scroll(+1000) # 偏移量,+是向上滚动,-是向下滚动 time.sleep(2) # 滚动间隔时间 def is_end_of_chat(): # Implement a method to detect if the current page is the last one # This is just a placeholder; you'll need to adjust it to your specific case # For example, you could compare the new screenshot with the previous one to check for changes return False def main(): page_number = 1 while True: capture_screenshot(page_number) if is_end_of_chat(): break scroll_chat() page_number += 1 print("Finished capturing all chat pages.") if __name__ == "__main__": main()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。