Commit c9b62377 authored by liyang's avatar liyang

fix:youtube 360P 每次6条

parent a94971b7
......@@ -4,7 +4,7 @@ import re
import time
import loguru
import pymysql.cursors
# import pymysql.cursors
import requests
from bs4 import BeautifulSoup
from datetime import datetime
......@@ -37,9 +37,10 @@ def reptile(browser=None, search_word=""):
# log.debug(classify_item_list)
length = len(classify_item_list)
for index in range(length):
# 暂时先爬取 第2个 分类
if 1 < index < 3:
classify_item_list[index].click()
time.sleep(1)
# time.sleep(0.1)
element_list = browser.find_elements('xpath', "//div[@class='r-ent']//div[@class='title']//a")
length_two = len(element_list)
for index_two in range(length_two):
......@@ -51,7 +52,7 @@ def reptile(browser=None, search_word=""):
# if matches:
# log.debug(f"找到了匹配的字符串:{matches}")
element_list[index_two].click()
time.sleep(1)
# time.sleep(0.1)
# 原链接
browser_current_url = browser.current_url
log.debug('网页链接' + str(browser_current_url))
......@@ -139,7 +140,7 @@ def reptile(browser=None, search_word=""):
}
# --------------- 组装数据 end---------------------
if search_word is "":
if search_word == "":
data.append(obj)
else:
# 使用正则表达式进行匹配
......@@ -156,7 +157,7 @@ def reptile(browser=None, search_word=""):
element_list = browser.find_elements('xpath', "//div[@class='r-ent']//div[@class='title']//a")
# 浏览器返回上一页
browser.back()
time.sleep(1)
# time.sleep(1)
# 重新获取
classify_item_list = browser.find_elements('xpath', "//div[@class='board-class']")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment