1

I am trying to write some code, to automatically fill this webform:

http://scoweb.sco.ca.gov/UCP/

Then read the returned results. I'll look for my name and notify myself when I have UCP.

I have tried writing programs in C#(System.Net), curl(in conjunction with formfind), Ruby(Mechanize), and Python(Scrapy, urllib2). All of my scripts work on regular HTML forms that communicate with databases, but this one returns nothing.

My theory is because the site uses ASP and I am failing to do something to account for that?

Any working code, though python preferred, filling the form and returning the results would be greatly appreciated.

2 Answers 2

0

I think the problem is because the form uses javascript. You can use selenium for such a thing http://seleniumhq.org/

1
  • This is a great tool. It's working as I wanted, but I still have to do some digging through the docs to figure out if and how I can save information to file... Thanks.
    – Peregrine
    Oct 26, 2012 at 23:31
0
#!/usr/bin/env python

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re

class Shiply(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.implicitly_wait(30)
        self.base_url = "http://scoweb.sco.ca.gov/"  #California UCP
        self.verificationErrors = []

    def test_shiply(self):
        driver = self.driver
        driver.get(self.base_url + "/UCP/")
        driver.find_element_by_id("ctl00_ContentPlaceHolder1_txtLastName").clear()
        driver.find_element_by_id("ctl00_ContentPlaceHolder1_txtLastName").send_keys("YOUR_NAME")
        driver.find_element_by_id("ctl00_ContentPlaceHolder1_btnSearch").click()

    def is_element_present(self, how, what):
        try: self.driver.find_element(by=how, value=what)
        except NoSuchElementException, e: return False
        return True

    def tearDown(self):
        self.driver.quit()
        self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
    unittest.main()

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.