2

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.

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):

from twill import get_browser
from twill.commands import *

username = "[email protected]" # 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()

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

Traceback (most recent call last):
  File "<pyshell#43>", line 1, in <module>
    b.showforms()
  File "C:\Python27\lib\site-packages\twill-0.9-py2.7.egg\twill\browser.py", line 225, in showforms
    forms = self.get_all_forms()
  File "C:\Python27\lib\site-packages\twill-0.9-py2.7.egg\twill\browser.py", line 259, in get_all_forms
    global_form = self._browser.global_form()
  File "C:\Python27\lib\site-packages\twill-0.9-py2.7.egg\twill\other_packages\_mechanize_dist\_mechanize.py", line 446, in global_form
    return self._factory.global_form
  File "C:\Python27\lib\site-packages\twill-0.9-py2.7.egg\twill\utils.py", line 334, in get_global_form
    return self.factory.global_form
  File "C:\Python27\lib\site-packages\twill-0.9-py2.7.egg\twill\other_packages\_mechanize_dist\_html.py", line 521, in __getattr__
    self.forms()
  File "C:\Python27\lib\site-packages\twill-0.9-py2.7.egg\twill\other_packages\_mechanize_dist\_html.py", line 534, in forms
    self._forms_factory.forms())
  File "C:\Python27\lib\site-packages\twill-0.9-py2.7.egg\twill\other_packages\_mechanize_dist\_html.py", line 226, in forms
    raise ParseError(exc)
ParseError: <unprintable ParseError object>

1 Answer 1

1

Yeah, the twill stuff for python is not the best documentation in the world. I think you can basically forget about the "get_browser" stuff. The twill stuff is a little clearer for me this way:

import twill.commands as twill

username = "[email protected]" # email for opendns
password = "thisisthepassword" # password for opendns

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

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

twill.submit("sign-in")

twill.showforms()

twill.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

twill.showforms()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.