Created
February 27, 2021 05:10
-
-
Save thefloodshark/030a3f99a66a6c04042f416c33669b74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Selenium written in Python | |
#Automates Bing searches | |
#Work in progress - streamline with dictionary/tuple/list/keys | |
#Uses Chrome and Chromedriver to run random Bing searches | |
#change timings and search queries to your liking | |
import time | |
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from selenium.webdriver.common.keys import Keys | |
options = Options() | |
options.add_argument("start-maximized") | |
options.add_argument("disable-infobars") | |
options.add_argument("--disable-extensions") | |
driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\LOCATION\chromedriver.exe') | |
#add your own location of chromedriver.exe | |
driver.get('https://login.live.com/login.srf?wa=wsignin1.0&rpsnv=13&ct=1522552641&rver=6.7.6631.0&wp=MBI&wreply=https%3a%2f%2fwww.bing.com%2fsecure%2fPassport.aspx%3frequrl%3dhttps%253a%252f%252fwww.bing.com%252f%253fwlexpsignin%253d1&lc=1033&id=264960&pcexp=false&CSRFToken=94467ae5-f34c-42a8-be9c-964caff9ac54&aadredir=1') | |
print("Page Title is : %s" %driver.title) | |
element = driver.find_element_by_xpath("//input[@class='form-control ltr_override input ext-input text-box ext-text-box' and @name='loginfmt']") | |
element.click() | |
element.clear() | |
element.send_keys("[email protected]") | |
#input your email above | |
time.sleep(2) | |
driver.find_element_by_id('idSIButton9').send_keys("\n") | |
time.sleep(2) | |
password = driver.find_element_by_xpath("//input[@class='form-control input ext-input text-box ext-text-box' and @name='passwd']") | |
password.click() | |
password.clear() | |
password.send_keys("YOURPASSWORD") | |
#replace the above with your Bing/Microsoft Rewards password | |
time.sleep(1) | |
driver.find_element_by_id('idSIButton9').send_keys("\n") | |
time.sleep(1) | |
#the following can be streamlined with dictionaries/lists/tuples | |
element = driver.find_element_by_id("sb_form_q") | |
element.send_keys("fcad") | |
element.send_keys(Keys.RETURN) | |
time.sleep(1.2) | |
element = driver.find_element_by_name("q") | |
element.clear() | |
element.send_keys("fadd") | |
element.send_keys(Keys.RETURN) | |
time.sleep(0.7) | |
element = driver.find_element_by_name("q") | |
element.clear() | |
element.send_keys("djdj") | |
element.send_keys(Keys.RETURN) | |
time.sleep(1.4) | |
element = driver.find_element_by_name("q") | |
element.clear() | |
element.send_keys("dkdk") | |
element.send_keys(Keys.RETURN) | |
time.sleep(1.6) | |
element = driver.find_element_by_name("q") | |
element.clear() | |
element.send_keys("sddjd") | |
element.send_keys(Keys.RETURN) | |
time.sleep(1.5) | |
element = driver.find_element_by_name("q") | |
element.clear() | |
element.send_keys("last") | |
element.send_keys(Keys.RETURN) | |
time.sleep(1) | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment