Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save komang4130/57b7420ee0b98b65139215f854b346d3 to your computer and use it in GitHub Desktop.
Save komang4130/57b7420ee0b98b65139215f854b346d3 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
usr = "komang123"
pwd = "123456"
driver = webdriver.Firefox()
cookie = {"key": "value"}
driver.add_cookie(cookie)
# And now output all the available cookies for the current URL
all_cookies = driver.get_cookies()
for cookie_name, cookie_value in all_cookies.items():
print "%s -> %s", cookie_name, cookie_value
# or you can use Chrome(executable_path="/usr/bin/chromedriver")
driver.get("http://192.168.1.9/login.php")
elem = driver.find_element_by_name("username")
elem.send_keys(usr)
elem = driver.find_element_by_name("password")
elem.send_keys(pwd)
elem.send_keys(Keys.RETURN)
while 1:
id = 1
while 1:
try:
driver.get("http://192.168.1.9/detail.php?id=" + str(id))
time.sleep(5)
if "Server not found" in driver.page_source:
break
if "404 Not Found" in driver.page_source :
break
else:
print driver.page_source
id = id + 1
except:
id = id + 1
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment