我正在编写一个简单的omagle机器人,以了解有关硒的更多信息。
我的便签应该做什么?
1。打开Omegle网站,写点兴趣,然后按文本按钮[此部分正在运行]
2。它应该将我定义的文本键入文本,然后单击Esc按钮,然后正确地重复此操作[这部分工作了]
下面是我的脚本。
import random
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
# Settings
tags = ['test']
browser = webdriver.Chrome()
print(">>Opening Browser window : ")
browser.get("https://www.omegle.com/")
print(">>Opening Site : ")
time.sleep(random.randint(2, 4))
print(">>loading page : ")
browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
text_area = browser.find_element_by_class_name("topicplaceholder")
text_area.click()
input = browser.find_element_by_class_name("newtopicinput")
for i in tags:
input.send_keys(i)
print(">>Tag Entered > " + i)
input.send_keys(Keys.RETURN)
time.sleep(random.randint(1, 3))
browser.find_element_by_xpath("//img[@id='textbtn']").click()
print("opening a new chat : ")
i = 0
while i <= 50:
try:
time.sleep(2)
browser.find_element_by_xpath("/html/body/div[6]/div/div/div[1]/div[1]/div/div[4]/div/div/img").click()
print("clicked Next chat button")
except:
try:
time.sleep(10)
time.sleep(3)
browser.find_element_by_xpath("//button[@class='disconnectbtn']").click()
print("ESCAPE pressed ")
print("waiting for 10 sec")
# Here messages add as manny as you want
browser.find_element_by_xpath("/html/body/div[5]/div/div/div[2]/table/tbody/tr/td[2]/div/textarea").send_keys(
"Hey")
print("hy sent")
browser.find_element_by_xpath("//button[@class='sendbtn']").click()
time.sleep(5)
browser.find_element_by_xpath("/html/body/div[5]/div/div/div[2]/table/tbody/tr/td[2]/div/textarea").send_keys(
"How are you?")
print("how are u sent")
browser.find_element_by_xpath("//button[@class='sendbtn']").click()
time.sleep(10)
browser.find_element_by_xpath("/html/body/div[5]/div/div/div[2]/table/tbody/tr/td[2]/div/textarea").send_keys(
"i am steve.")
print("i am steve")
browser.find_element_by_xpath("//button[@class='sendbtn']").click()
time.sleep(5)
i += 1
print(">Number Of messages send : ", str(i))
except:
print("pass")
try:
browser.find_element_by_xpath("/html/body/div[5]/div/div/div[1]/div[1]/div/div[6]/div/div/img").click()
print("clicked Next chat button")
except:
browser.find_element_by_xpath("//button[@class='disconnectbtn']").click()
print("ESCAPE pressed ")
browser.find_element_by_xpath("//button[@class='disconnectbtn']").click()
print("ESCAPE pressed ")