Commit 3769935a authored by liyang's avatar liyang

fix:爬取数据入库

parent 61a8d894
...@@ -120,14 +120,20 @@ def reptile(browser=None, search_word=""): ...@@ -120,14 +120,20 @@ def reptile(browser=None, search_word=""):
"link": browser_current_url, "link": browser_current_url,
"reptileTime": str(int(time.time())) "reptileTime": str(int(time.time()))
} }
# 使用正则表达式进行匹配
matches = re.findall(search_word, element_title.text) # ------------------------------------------------------
# 打印匹配结果
if matches:
# log.debug(f"找到了匹配的字符串:{matches}")
data.append(obj) data.append(obj)
else: # # 使用正则表达式进行匹配
log.debug("未找到匹配的字符串") # matches = re.findall(search_word, element_title.text)
# # 打印匹配结果
# if matches:
# # log.debug(f"找到了匹配的字符串:{matches}")
# data.append(obj)
# else:
# log.debug("未找到匹配的字符串")
# ------------------------------------------------------
# 浏览器返回上一页 # 浏览器返回上一页
browser.back() browser.back()
element_list = browser.find_elements('xpath', "//div[@class='r-ent']//div[@class='title']//a") element_list = browser.find_elements('xpath', "//div[@class='r-ent']//div[@class='title']//a")
......
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