clickbot.py 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. from selenium import webdriver
  2. from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  3. import time
  4. import os
  5. import urllib.parse
  6. from selenium.webdriver.support.ui import WebDriverWait
  7. from selenium.webdriver.common.by import By
  8. from selenium.webdriver.support import expected_conditions as EC
  9. import codecs
  10. import random
  11. from bs4 import BeautifulSoup
  12. import requests
  13. import time
  14. import rpyc
  15. import sys
  16. import docker
  17. headers = {
  18. "Authorization": "Bearer " + "t35vhZtWNgvDNWHc3DJh0OKll3mcB9GvC8K2EAkBug2",
  19. "Content-Type": "application/x-www-form-urlencoded"
  20. }
  21. def send_msg(kw):
  22. params = {"message": "處理關鍵字: "+kw}
  23. r = requests.post("https://notify-api.line.me/api/notify",headers=headers, params=params)
  24. def empty_query(q):
  25. global driver
  26. googleurl='https://www.google.com/search?q='+urllib.parse.quote(q)
  27. driver.get(googleurl)
  28. time.sleep(3)
  29. def process_query(qs):
  30. q=qs[0]
  31. domain=qs[2]
  32. cnt=qs[1]
  33. global driver
  34. googleurl='https://www.google.com/search?q='+urllib.parse.quote(q)
  35. driver.get(googleurl)
  36. time.sleep(3)
  37. if cnt > 0:
  38. for i in range(cnt):
  39. elmt=driver.find_element_by_xpath("//a[@id='pnnext']")
  40. webdriver.ActionChains(driver).move_to_element(elmt).perform()
  41. webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
  42. time.sleep(3)
  43. elmts=driver.find_elements_by_xpath("//div[@class='g']//div[@class='yuRUbf']//a")
  44. idx=1
  45. ranking=-1
  46. for elmt in elmts:
  47. href=elmt.get_attribute('href')
  48. txt=elmt.text
  49. if len(txt)>10:
  50. # if 'hhh.com.tw' in href:
  51. # if 'hhh.com.tw' in href:
  52. # if 'ai.choozmo.com' in href:
  53. if domain in href:
  54. # if 'searchome.net' in href:
  55. webdriver.ActionChains(driver).move_to_element(elmt).perform()
  56. webdriver.ActionChains(driver).move_to_element(elmt).click().perform()
  57. break
  58. result=[]
  59. client = docker.from_env()
  60. ls=client.containers.list()
  61. print(ls)
  62. ls[0].restart()
  63. time.sleep(10)
  64. options = webdriver.ChromeOptions()
  65. driver = webdriver.Remote(
  66. command_executor='http://127.0.0.1:4444/wd/hub',
  67. #command_executor='http://192.53.174.202:4444/wd/hub',
  68. #command_executor='http://172.104.93.163:4444/wd/hub',
  69. #command_executor='http://dev2.choozmo.com:14444/wd/hub',
  70. desired_capabilities=options.to_capabilities())
  71. #desired_capabilities=DesiredCapabilities.CHROME)
  72. driver.set_window_size(1400,1000)
  73. qlist=['大進設計 583','大進設計 免費專線','大進設計 林函青','大進設計 hhh','大進設計 林函青設計師 hhh','大進空間設計 hhh','林函青 hhh']
  74. #qlist=['AI Spokesgirl','choozmo ai spokesgirl','choozmo ai 主播','choozmo 國際代言人','choozmo 國際主播','choozmo ai短影片','choozmo 短影片','AI虛擬主播 技術 choozmo','choozmo ai短影片','choozmo 虛擬人','choozmo 虛擬播報員','choozmo ai video','choozmo virtual presenter','choozmo virtual avatar','choozmo ai spokesperson']
  75. #qlist+=['ai seowriter choozmo','gpt3 choozmo','蝦皮 seo site:ai.choozmo.com','vtuber choozmo','seo site:ai.choozmo.com','台灣第一位ai主播','ai主播 2021..2021','AI主播韓小夏 choozmo','ai spokesgirl','ai主播 韓小夏 choozmo','主播 韓小夏 choozmo','ai spokesgirl 集仕多','ai 合成 主播 choozmo','台灣AI主播 choozmo','台灣 ai主播 choozmo']
  76. #qlist+=['ai seowriter choozmo','gpt3 choozmo','蝦皮 seo site:ai.choozmo.com','vtuber choozmo','seo site:ai.choozmo.com','youtube seo choozmo','video marketing choozmo','deepmind choozmo']
  77. #qlist=['ppt to mp4 choozmo','slides to MP4 choozmo','Convert Your Slide Into Video choozmo','ppt video choozmo','PowerPoint Into a Video choozmo']
  78. #qlist=['ai seowriter choozmo','gpt3 choozmo','youtube seo choozmo','video marketing choozmo','人工智慧 choozmo','text to video choozmo','contentfly choozmo','Uberduck choozmo','文本 choozmo','slide video choozmo','unicorn choozmo']
  79. #qlist+=[('local seo choozmo',0),('video production choozmo',0),('Google Slides choozmo',0),('video production choozmo',0),('絆愛 vtuber choozmo',0),('vtuber 鯊魚 choozmo',0),('ai unicorn choozmo',0),('韓國 ai 主播 choozmo',0)]
  80. #qlist+=[('seo 推薦 choozmo',0),('choozmo seo 推薦',0),('台灣 vtuber choozmo',0),('vtuber choozmo',0),('台灣 choozmo',0),('Anthony Bourdain choozmo',0),('角巻 choozmo',0),('竹北 seo choozmo',0)]
  81. #qlist=[('ai 主播',2,'choozmo.com'),('ai主播',2,'choozmo.com'),('台灣 vtuber choozmo',0,'choozmo.com'),('vtuber choozmo',0,'choozmo.com'),('vtuber 是什麼 choozmo',0,'choozmo.com'),('vtuber site:choozmo.com',0,'choozmo.com')]
  82. #qlist+=[('seo 推薦 choozmo',0,'choozmo.com'),('蝦皮 seo site:ai.choozmo.com',0,'choozmo.com'),('ppt to mp4 choozmo',0,'choozmo.com')]
  83. #qlist+=[('預售屋客變教學',0,'hhh.com.tw'),('預售屋客變',0,'hhh.com.tw'),('預售屋客變流程',0,'hhh.com.tw'),('預售屋客變省錢',0,'hhh.com.tw'),('所有的地方都能進行客變嗎',0,'hhh.com.tw'),('什麼是客變',0,'hhh.com.tw')]
  84. #qlist=[('大欣室內裝修設計',0,'hhh.com.tw'),('宋茂松',0,'hhh.com.tw'),('大欣室內裝修設計 宋茂松',0,'hhh.com.tw'),('大欣室內設計',0,'hhh.com.tw'),('大欣室內裝修',0,'hhh.com.tw'),('大欣室內裝修',0,'hhh.com.tw'),('大欣室內裝修影音',0,'hhh.com.tw')]
  85. #qlist=[('居家風水',0),('風水',2)]
  86. #qlist+=[('DHIA 黃靜文',0,'hhh.com.tw'),('藏風空間設計',1,'hhh.com.tw'),('天花板設計',1,'hhh.com.tw'),('陽台佈置',0,'hhh.com.tw'),('設計師',0,'hhh.com.tw'),('玄關設計',0,'hhh.com.tw'),('廚房設計',0,'hhh.com.tw'),('風水',2,'hhh.com.tw'),('住宅風水',1,'hhh.com.tw'),('居家風水',0,'hhh.com.tw'),('居家 風水',0,'hhh.com.tw'),('客廳連廚房',0,'hhh.com.tw'),('前陽台玄關',1,'hhh.com.tw')]
  87. #qlist=[('大欣室內',1,'hhh.com.tw'),('雲頂室內',1,'hhh.com.tw'),('沐熙空間',1,'hhh.com.tw'),('丸美製作',1,'hhh.com.tw'),('藏風空間設計',1,'hhh.com.tw'),('浤淇室內裝修',1,'hhh.com.tw'),('澄羿空間',1,'hhh.com.tw')]
  88. #qlist=[('預售屋客變',0,'hhh.com.tw'),('DHIA 黃靜文',0,'hhh.com.tw'),('DHIA hhh',0,'hhh.com.tw'),('DHIA 設計',0,'hhh.com.tw'),('DHIA 室內設計',0,'hhh.com.tw'),('DHIA 設計師',0,'hhh.com.tw')]
  89. ##AR/VR Focused On-demand Micro Exhibition
  90. #while True:
  91. for i in range(80):
  92. q=random.choice(qlist)
  93. print(q)
  94. # prob=random.randint(0,4)
  95. prob=random.randint(0,2)
  96. # if prob <=1:
  97. if True:
  98. # q=qlist[0]
  99. print(q[0])
  100. process_query(q)
  101. send_msg(q[0])
  102. else:
  103. empty_query(q)
  104. intsleep=random.randint(5,12)
  105. time.sleep(intsleep)