wangkun преди 1 година
родител
ревизия
c0b8624dc1
променени са 1 файла, в които са добавени 6 реда и са изтрити 9 реда
  1. 6 9
      xigua/xigua_search/xigua_search.py

+ 6 - 9
xigua/xigua_search/xigua_search.py

@@ -729,10 +729,9 @@ class XiguasearchScheduling:
         if driver.find_elements(By.XPATH, '//*[@class="xg-notification-close"]') != 0:
             driver.find_element(By.XPATH, '//*[@class="xg-notification-close"]').click()
 
-        page = 0
-        while True:
-            # 查找视频列表
-            video_elements = driver.find_elements(By.XPATH, '//*[@class="HorizontalFeedCard__coverWrapper disableZoomAnimation"]')
+        # 查找视频列表
+        video_elements = driver.find_elements(By.XPATH, '//*[@class="HorizontalFeedCard__coverWrapper disableZoomAnimation"]')
+        for i in range(100):
             if len(video_elements) == 0:
                 Common.logger(log_type, crawler).warning('未搜索到视频\n')
                 Common.logging(log_type, crawler, env, '未搜索到视频\n')
@@ -746,17 +745,15 @@ class XiguasearchScheduling:
                 Common.logging(log_type, crawler, env, f"已扫描 {len(video_elements)} 条视频\n")
                 break
             else:
-                page += 1
                 # 拖动列表最后一条视频至屏幕中间
                 Common.logger(log_type, crawler).info("拖动列表最后一条视频至屏幕中间")
                 Common.logging(log_type, crawler, env, "拖动列表最后一条视频至屏幕中间")
                 action = ActionChains(driver)
                 action.move_to_element(video_elements[-1]).perform()
                 time.sleep(1)
-                driver.get_screenshot_as_file(f"./{crawler}/photos/{page}.png")
-                if page == 50:
-                    Common.logger(log_type, crawler).info(f"{driver.page_source}")
-                    return
+
+                # 重新查找视频列表
+                video_elements = driver.find_elements(By.XPATH, '//*[@class="HorizontalFeedCard__coverWrapper disableZoomAnimation"]')
 
         for i, video_element in enumerate(video_elements):
             try: