获得 'FormNotFoundError' 机械化 Python
Getting 'FormNotFoundError' in mechanize Python
我正在使用 beautiful soup 和 mechanize 来抓取银行网站的网页。
import re
import mechanize
br = mechanize.Browser()
br.set_handle_robots(False)
br.set_handle_equiv(False)
response = br.open("https://m.netbanking.hdfcbank.com/netbanking/")
br.select_form(nr=0)
br.form['fldLoginUserId'] = "131325"
br.submit()
我需要在客户 ID 文本框中输入值,但每次都出现异常。谁能帮帮我。
Traceback (most recent call last):
File ".\main.py", line 12, in <module>
br.select_form(nr=0)
File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 669, in select_form
raise FormNotFoundError("no form matching " + description)
mechanize._mechanize.FormNotFoundError: no form matching nr 0
尝试使用 selenium 完成此任务。
from selenium import webdriver
driver = webdriver.Firefox(executable_path='./drivers/geckodriver')
driver.get('https://m.netbanking.hdfcbank.com/netbanking/')
driver.find_element_by_xpath('//*[@id="fldLoginUserId"]').click()
driver.find_element_by_xpath('//*[@id="fldLoginUserId"]').send_keys('131325')
driver.find_element_by_xpath('//*[@id="logintable"]//input[@type="submit"]').click()
我正在使用 beautiful soup 和 mechanize 来抓取银行网站的网页。
import re
import mechanize
br = mechanize.Browser()
br.set_handle_robots(False)
br.set_handle_equiv(False)
response = br.open("https://m.netbanking.hdfcbank.com/netbanking/")
br.select_form(nr=0)
br.form['fldLoginUserId'] = "131325"
br.submit()
我需要在客户 ID 文本框中输入值,但每次都出现异常。谁能帮帮我。
Traceback (most recent call last):
File ".\main.py", line 12, in <module>
br.select_form(nr=0)
File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 669, in select_form
raise FormNotFoundError("no form matching " + description)
mechanize._mechanize.FormNotFoundError: no form matching nr 0
尝试使用 selenium 完成此任务。
from selenium import webdriver
driver = webdriver.Firefox(executable_path='./drivers/geckodriver')
driver.get('https://m.netbanking.hdfcbank.com/netbanking/')
driver.find_element_by_xpath('//*[@id="fldLoginUserId"]').click()
driver.find_element_by_xpath('//*[@id="fldLoginUserId"]').send_keys('131325')
driver.find_element_by_xpath('//*[@id="logintable"]//input[@type="submit"]').click()