This is a python program that automates skipping through users on a chat website called talkwithstrangers using the Selenium Webdriver and BeautifulSoup modules of Python.
The first part uses Selenium to open the browser:
from selenium import webdriver
driver = webdriver.Chrome('C:\SeleniumDrivers\chromedriver.exe')
userName = 'null'
driver.get('https://talkwithstranger.com/talk-to-strangers')
The second part is a while
loop that runs while the username has not met the required conditions:
while 'female' not in userName or 'Female' not in userName:
driver.get('https://talkwithstranger.com/talk-to-strangers')
html = driver.execute_script("return document.documentElement.innerHTML;")
from bs4 import BeautifulSoup
soup = BeautifulSoup(html, 'html5lib')
userVal = soup.find(class_='alert text-center alert-success')
userNames = userVal.find_all('b')
def getName(userNames):
for name in userNames:
return name.prettify()
userName = getName(userNames)
The code is running fine but the problem is the efficiency and runtime.