Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Parse Error when using showforms() command with Twill

jezzmcquirejezzmcquire Posts: 2Member
Hi, bare with me with this as it's my first python program. I've spent a few hours Googling and testing for a solution but I'm at that point where I think I just need a helping hand from one of you kind people.

My idea for this program is to have a simple (supposedly) script that monitors what time it is, and when it's in a certain time range (for example 6am to 7pm) it navigates to opendns.com and blocks certain websites using the web content filtering feature.

Now because I'm quite the novice when it comes to python I thought I'd start it simple and just figure out the commands to login to the website and block a website and worry about the monitoring of the time etc later on. But sadly I'm having trouble with that aswell.

I'm using http://twill.idyll.org/ but not sure if that's a good idea or not. It's the only one I could find apart from mechanize (Which I couldn't find the right documentation for, but perhaps I'm just not looking in the right places)
Here is my code (well, it's not really code yet. Just a list of commands for the Python Shell.):

[code]
from twill import get_browser
from twill.commands import *

username = "username@email.com" # email for opendns
password = "thisisthepassword" # password for opendns
b = get_browser()

b.go("https://dashboard.opendns.com/")
b.showforms()

fv("2", "username", username)
fv("2", "password", password)
showforms()

submit("sign-in")

b.showforms()

b.go ("https://dashboard.opendns.com/settings/*MYNETWORKID*/content_filtering") # I replaced my network ID due to privacy reasons but this is basically the URL to the web content filtering page on OpenDNS for a network

b.showforms()
[/code]


Now that's where my problem starts. On that last b.showforms() I get an error:

[code]
Traceback (most recent call last):
File "", line 1, in
b.showforms()
File "C:Python27libsite-packages will-0.9-py2.7.egg willrowser.py", line 225, in showforms
forms = self.get_all_forms()
File "C:Python27libsite-packages will-0.9-py2.7.egg willrowser.py", line 259, in get_all_forms
global_form = self._browser.global_form()
File "C:Python27libsite-packages will-0.9-py2.7.egg willother_packages_mechanize_dist_mechanize.py", line 446, in global_form
return self._factory.global_form
File "C:Python27libsite-packages will-0.9-py2.7.egg willutils.py", line 334, in get_global_form
return self.factory.global_form
File "C:Python27libsite-packages will-0.9-py2.7.egg willother_packages_mechanize_dist_html.py", line 521, in __getattr__
self.forms()
File "C:Python27libsite-packages will-0.9-py2.7.egg willother_packages_mechanize_dist_html.py", line 534, in forms
self._forms_factory.forms())
File "C:Python27libsite-packages will-0.9-py2.7.egg willother_packages_mechanize_dist_html.py", line 226, in forms
raise ParseError(exc)
ParseError:
[/code]

Could anyone help me out or point me in the right direction? If you think I'm going about it completely wrong please do tell me, even if you think I should use another language. Like I said this is my first program so I'm not overly attached to Python, I just had been told it was perfect for a program like this.
Sorry If I posted this question in the wrong format or something. I tried my best to adhere to the guidelines, if there's anything I need to change or more information I need to provide just let me know.
Thanks in advance for anyone who takes the time to help me, I know this probably seems like a question with an obvious answer to most of you.
Sign In or Register to comment.