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/3d61ae4970fbcd55883bb890b10d1a5c to your computer and use it in GitHub Desktop.
Save komang4130/3d61ae4970fbcd55883bb890b10d1a5c to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pickle
import time
usr = "komang123"
pwd = "123456"
driver = webdriver.Firefox()
# or you can use Chrome(executable_path="/usr/bin/chromedriver")
driver.get("http://192.168.43.7/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)
driver.get("http://192.168.43.7/management.php")
pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
driver.add_cookie(cookie)
print cookie
while 1:
id = 1
while 1:
driver.get("http://192.168.43.7/detail.php?id=" + str(id))
time.sleep(5)
if "404 Not Found" in driver.page_source :
break
else:
print driver.page_source
id = id + 1
time.sleep(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment