page_test.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import os
  2. import sys
  3. sys.path.append(os.path.dirname(os.path.dirname(__file__)))
  4. from douyin.flow import check_page
  5. from dp.page import page
  6. from conf.config import logger,OUTPUT
  7. from database.config import minio_block
  8. from database.s3 import S3Object,S3
  9. from database.config import minio_client
  10. from pathlib import Path
  11. from douyin import chat_test
  12. tab=page.tab
  13. def save_html_to_s3():
  14. file_name = '点击陌生人对话框.html'
  15. page_dir = Path(r'I:\code\ai-yunying\live-online-people\output\page\\')
  16. file_path = page_dir/file_name
  17. f = open(file_path, 'w')
  18. f.write(tab.html)
  19. s3minio = S3(bucket='public',client=minio_client)
  20. base_path = '/md/ai-yunying/'
  21. obj_name = base_path+ s3minio.get_object_name_by_time() + '-'+ file_name
  22. res = s3minio.fput(r'I:\code\ai-yunying\live-online-people\output\page\\'+file_name, obj_name)
  23. logger.info(f"{res.bucket_name } {res.object_name} {res._http_headers}")
  24. def check_msg():
  25. from douyin.flow import conversation,unread_msg
  26. def main():
  27. chat_test.Chat()
  28. # save_html_to_s3()
  29. # res = minio_client.fput_object(bucket_name='public', object_name=base_path+file_name, file_path=r"I:\code\ai-yunying\live-online-people\output\page\\"+file_name,content_type= 'text/html')
  30. # ele_dlg = tab.ele('xpath://div[@data-e2e="listDlg-container"]')
  31. # logger.info(f"{ele_dlg.text}")
  32. # check_has_im_msg_flow(home_url="https://www.douyin.com/user/self")
  33. # S3Object(path='runtime/check_msg-stranger-msg.html').put(tab.html)
  34. # f = open(r'I:\code\ai-yunying\live-online-people\output\page\点击陌生人消息.html', 'w')
  35. # f.write(tab.html)
  36. if __name__ == "__main__":
  37. main()