I am developing a web scraper in python that what it does is to take users and passwords from a database and then go to an external web page and fill out the form to later log in, it works perfect with the first username and password, but when it happens to the second it throws me that the "submit" button can not be located.
Any ideas?
I leave the code that I am using:
#!/usr/bin/python
# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import MySQLdb
db = MySQLdb.connect(host="127.0.0.1", user="root", passwd="", db="seliso")
cursor = db.cursor()
cursor.execute("SELECT * FROM usuarios")
for row in cursor.fetchall():
rfc = row[1]
clave = row[2]
driver = webdriver.Firefox()
driver.get("https://login.siat.sat.gob.mx/nidp/idff/sso?id=mat-ptsc-totp&sid=10&option=credential&sid=10")
username = driver.find_element_by_name("Ecom_User_ID")
password = driver.find_element_by_name("Ecom_Password")
username.send_keys(rfc)
password.send_keys(clave)
submit = driver.find_element_by_name("submit")
submit.click()
driver.get("https://www.siat.sat.gob.mx/PTSC/")
link = driver.find_element_by_link_text("Buzón tributario")
link.click()
driver.get("https://www.siat.sat.gob.mx/PTSC/cerrarSesion")
driver.close()
db.close()