I'm trying to set the controls on a form from disabled readonly to something usable. But the problem is the control has no name. I saw a previous post where someone else solved this problem. But I have been unable to implement their solution correctly. Since I am new to python, I was hoping someone could shed some light on what I'm doing wrong.
Previous post: Use mechanize to submit form without control name
Here is my code:
import urllib2
from bs4 import BeautifulSoup
import cookielib
import urllib
import requests
import mechanize
# Log-in to wsj.com
cj = mechanize.CookieJar()
br = mechanize.Browser()
br.set_cookiejar(cj)
br.set_handle_robots(False)
# The site we will navigate into, handling it's session
br.open('https://id.wsj.com/access/pages/wsj/us/login_standalone.html?mg=id-wsj')
# Select the first (index zero) form
br.select_form(nr=0)
# Returns None
forms = [f for f in br.forms()]
print forms[0].controls[6].name
# Returns set_value not defined
set_value(value,
name=None, type=None, kind=None, id=None, nr=None,
by_label=False, # by_label is deprecated
label=None)
forms[0].set_value("LOOK!!!! I SET THE VALUE OF THIS UNNAMED CONTROL!",
nr=6)
control.readonly = False
control.disabled = True