# @Author: wangkun # @Time: 2月 25, 2022 import difflib import logging import os import sys import time from selenium.webdriver import DesiredCapabilities from selenium.webdriver.common.by import By from seleniumwire import webdriver sys.path.append(os.getcwd()) from main.feishu_lib import Feishu path = "../videoinfo/" class Demo: @classmethod def read_videoname(cls): with open(path + "videoname.txt", "r", encoding="utf8") as f: content = f.read() name = content return name @classmethod def get_sht(cls): sht = Feishu.get_values_batch('recommend', 'shipinhao', 'KsVtLe') title = '穷人怎么变富上海爷叔句句肺腑,短短一席话令人深思' if title in [x for y in Feishu.get_values_batch('demo', 'shipinhao', 'KsVtLe') for x in y]: print('yes') else: print('no') @classmethod def get_hotword(cls): # 打印请求配置 ca = DesiredCapabilities.CHROME ca["goog:loggingPrefs"] = {"performance": "ALL"} # driver初始化 driver = webdriver.Chrome(desired_capabilities=ca) # driver = webdriver.Chrome(desired_capabilities=ca, options=chrome_options) driver.implicitly_wait(10) print('打开百度网页') driver.get('https://www.baidu.com/') driver.maximize_window() driver.implicitly_wait(10) time.sleep(1) hot_words = driver.find_elements(By.XPATH, '//li[@class="hotsearch-item odd"]') for i in range(len(hot_words)): print(i) hot_word = hot_words[i].find_element(By.XPATH, '//span[@class="title-content-title"]') print(hot_word) # 比较字符串相似度 @classmethod def str_similarity(cls): str1 = '男童不小心将玩具扔到姑父身上,姑父一耳光将男童扇倒地。目前家人已报警处理,孩子身体检查无大碍。#家庭 #监控下的惊险一幕 ' str2 = '...姑父一耳光将男童扇倒地。目前家人已报警处理,孩子身体检查无大碍。#家庭 #监控下的惊险一幕' print(difflib.SequenceMatcher(None, str1, str2).quick_ratio()) # print(type(difflib.SequenceMatcher(None, str1, str2).quick_ratio())) if __name__ == "__main__": Demo.get_sht() pass