Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- from time import sleep
- from selenium.common.exceptions import NoSuchElementException
- from selenium.common.exceptions import InvalidElementStateException
- x = webdriver.Chrome(executable_path='G:\Python\Driver\chromedriver')
- x.get('https://www.omegle.com/')
- print("Visit Omegle")
- sleep(10)
- new_chat = x.find_element_by_id('textbtn').click()
- print("Start New Chat")
- chat_total = 0
- chat_completed = 0
- chat_closed = 0
- count = 0
- def restart():
- global chat_total, chat_completed, chat_closed, count
- next_chat = x.find_element_by_class_name('disconnectbtn').click()
- sleep(1)
- chat_total +=1
- def send_new(textmsg):
- msg = x.find_element_by_xpath('/html/body/div[5]/div/div/div[2]/table/tbody/tr/td[2]/div/textarea')
- send_msg = x.find_element_by_class_name('sendbtn')
- msg.send_keys(textmsg)
- send_msg.click()
- def bot_start():
- global chat_total, chat_completed, chat_closed, count
- while count == 0:
- try:
- chat_closed = chat_total - chat_completed
- print("Total Chat: " + str (chat_total) + " - Closed: " + str (chat_closed) + " - Completed: " + str (chat_completed))
- #print("Start New Chat")
- sleep(5)
- if ("Stranger has disconnected." in x.page_source) or ("You have disconnected." in x.page_source):
- restart()
- continue
- else:
- send_new("F17")
- sleep(3)
- if ("Stranger has disconnected." in x.page_source) or ("You have disconnected." in x.page_source):
- restart()
- continue
- else:
- send_new("Ho deciso di fare una raccolta di tutte le mie foto HOT")
- sleep(3) #http://bit.ly/2r6CFD4
- if ("Stranger has disconnected." in x.page_source) or ("You have disconnected." in x.page_source):
- restart()
- continue
- else:
- send_new("se ti va di vederla e darmi un parere la trovi qua: https://about.me/anna_tonarelli")
- sleep(3)
- if ("Stranger has disconnected." in x.page_source) or ("You have disconnected." in x.page_source):
- restart()
- continue
- else:
- send_new("fammi sapere che ne pensi, ci ho messo impegno")
- sleep(3)
- if ("Stranger has disconnected." in x.page_source) or ("You have disconnected." in x.page_source):
- restart()
- continue
- else:
- #print("Finish Chat")
- chat_completed +=1
- next_chat = x.find_element_by_class_name('disconnectbtn').click()
- sleep(1)
- next_chat = x.find_element_by_class_name('disconnectbtn').click()
- sleep(1)
- next_chat = x.find_element_by_class_name('disconnectbtn').click()
- except NoSuchElementException:
- continue
- except InvalidElementStateException:
- restart()
- bot_start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement