demo.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # @Author: wangkun
  2. # @Time: 2月 25, 2022
  3. import difflib
  4. import logging
  5. import os
  6. import sys
  7. import time
  8. from selenium.webdriver import DesiredCapabilities
  9. from selenium.webdriver.common.by import By
  10. from seleniumwire import webdriver
  11. sys.path.append(os.getcwd())
  12. from main.feishu_lib import Feishu
  13. path = "../videoinfo/"
  14. class Demo:
  15. @classmethod
  16. def read_videoname(cls):
  17. with open(path + "videoname.txt", "r", encoding="utf8") as f:
  18. content = f.read()
  19. name = content
  20. return name
  21. @classmethod
  22. def get_sht(cls):
  23. sht = Feishu.get_values_batch('recommend', 'shipinhao', 'KsVtLe')
  24. title = '穷人怎么变富上海爷叔句句肺腑,短短一席话令人深思'
  25. if title in [x for y in Feishu.get_values_batch('demo', 'shipinhao', 'KsVtLe') for x in y]:
  26. print('yes')
  27. else:
  28. print('no')
  29. @classmethod
  30. def get_hotword(cls):
  31. # 打印请求配置
  32. ca = DesiredCapabilities.CHROME
  33. ca["goog:loggingPrefs"] = {"performance": "ALL"}
  34. # driver初始化
  35. driver = webdriver.Chrome(desired_capabilities=ca)
  36. # driver = webdriver.Chrome(desired_capabilities=ca, options=chrome_options)
  37. driver.implicitly_wait(10)
  38. print('打开百度网页')
  39. driver.get('https://www.baidu.com/')
  40. driver.maximize_window()
  41. driver.implicitly_wait(10)
  42. time.sleep(1)
  43. hot_words = driver.find_elements(By.XPATH, '//li[@class="hotsearch-item odd"]')
  44. for i in range(len(hot_words)):
  45. print(i)
  46. hot_word = hot_words[i].find_element(By.XPATH, '//span[@class="title-content-title"]')
  47. print(hot_word)
  48. # 比较字符串相似度
  49. @classmethod
  50. def str_similarity(cls):
  51. str1 = '男童不小心将玩具扔到姑父身上,姑父一耳光将男童扇倒地。目前家人已报警处理,孩子身体检查无大碍。#家庭 #监控下的惊险一幕 '
  52. str2 = '...姑父一耳光将男童扇倒地。目前家人已报警处理,孩子身体检查无大碍。#家庭 #监控下的惊险一幕'
  53. print(difflib.SequenceMatcher(None, str1, str2).quick_ratio())
  54. # print(type(difflib.SequenceMatcher(None, str1, str2).quick_ratio()))
  55. if __name__ == "__main__":
  56. Demo.get_sht()
  57. pass