KS3 Computing/Projects Ideas/Hack applications/find-solution-for-find-the-number

From Wikibooks, open books for an open world
< KS3 Computing‎ | Projects Ideas‎ | Hack applications
Jump to navigation Jump to search

1. start with bbc end with ciphertechs[edit]

from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://www.google.com'
browser.get(url)
open the page http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl 


Answer:

make this code change
from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)



2.Open five times (manually)[edit]

Answer:

from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)


3.Open five times (call the function browser.get five times, each time passing the url argument)[edit]

Answer:

from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)
browser.get(url)
browser.get(url)
browser.get(url)
browser.get(url)


4.Open five times (with loop))[edit]

Answer:

from selenium import webdriver

browser = webdriver.Firefox()

url    = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
num = 0
while num < 5:
  browser.get(url)



5. Open once and enter value in field[edit]

Answer:

from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

elem = browser.find_element_by_name('userguess')  # Find the search box
elem.send_keys(111)

form = browser.find_element_by_name('F')
form.submit()



6. Open once and enter 5 value in field[edit]

Answer:

from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

elem = browser.find_element_by_name('userguess')  # Find the search box
elem.send_keys(111)

form = browser.find_element_by_name('F')
form.submit()

elem = browser.find_element_by_name('userguess')  # Find the search box
elem.send_keys(112)

form = browser.find_element_by_name('F')
form.submit()

elem = browser.find_element_by_name('userguess')  # Find the search box
elem.send_keys(113)

form = browser.find_element_by_name('F')
form.submit()

elem = browser.find_element_by_name('userguess')  # Find the search box
elem.send_keys(114)

form = browser.find_element_by_name('F')
form.submit()

elem = browser.find_element_by_name('userguess')  # Find the search box
elem.send_keys(115)

form = browser.find_element_by_name('F')
form.submit()


7. Open once and enter value using function[edit]

Answer:

from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

def try_Number (value):
  elem = browser.find_element_by_name('userguess')  # Find the search box
  elem.send_keys(value)

  form = browser.find_element_by_name('F')
  form.submit()

try_Number(111)


8. Open once and enter 5 values using function[edit]

Answer:

from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

def try_Number (value):
  elem = browser.find_element_by_name('userguess')  # Find the search box
  elem.send_keys(value)

  form = browser.find_element_by_name('F')
  form.submit()

try_Number(111)
try_Number(112)
try_Number(113)
try_Number(114)
try_Number(115)


8. Open once and enter 5 values using function and a loop[edit]

Answer:

from selenium import webdriver

browser = webdriver.Firefox()
url = 'http://vicnum.ciphertechs.com/cgi-bin/guessnum1.pl'
browser.get(url)

def try_Number (value):
  elem = browser.find_element_by_name('userguess')  # Find the search box
  elem.send_keys(value)

  form = browser.find_element_by_name('F')
  form.submit()

num = 0
while num < 10:
  try_Number("00" + str(num))
  num += 1