How do I automate web form-entry tasks?
November 14, 2014 11:44 AM   Subscribe

I have a pretty simple but repetitive task: From a starting spreadsheet, I have to input information from each row into a web form. The web form generates .pdf files, which are downloaded and need to be renamed based on data from the spreadsheet. What software can I use for a task like this? What approaches can I take for automating this and similar tasks in the future?

This seems like an easy thing to automate, but a few searches turn up no easy entry point for doing tasks like this - Greasemonkey doesn't seem to interact with spreadsheets; a lot of other macro software seems enterprise-priced.

I have experience with Javascript but that's about it.
posted by LSK to Computers & Internet (6 answers total) 2 users marked this as a favorite
Need more information about what the "web form" is. This is something that maybe you can bypass the form using .csv, but again, it depends on what the "web form" is, who hosts it, what is processing the form data, etc.
posted by humboldt32 at 11:52 AM on November 14, 2014

Response by poster: The form is pretty basic HTML - I can't link to it because it's behind a login window and contains proprietary information, but it's just a set of text fields and radio buttons. You can tab between them, etc. I can get the field names and use Javascript like javascript:document.getElementById("elementName").value="intendedValue"; to set the value but I don't know how to do that programmatically from a CSV.
posted by LSK at 12:00 PM on November 14, 2014

Is the form and it's processor under your control?

It seems a bit like your trying to make a tape, of a cd, of a tape, of an album. If you take my meaning. I'm sorry, I don't have a good recomendation for automating filling in the form.
posted by humboldt32 at 12:10 PM on November 14, 2014

Best answer: A combination of Autohotkey and some scripting is probably what you're looking for.
posted by trunk muffins at 12:11 PM on November 14, 2014

Best answer: Bypass the browser entirely--it's only doing the GET/POST and interpreting the results for you

1) Web form accepts GET calls
2) You're willing to invest in a little time to script this.

Pseudo code:
for row in csvFile:
    url = "{0}&variableName2={1}".format( row[ 0 ], row [ 1 ] )
    result = wget url
    if result != expected:
        raise exception
        save( result, "{0}.pdf".format( row[ 3 ] ) )
you can find the first part of URL by looking for the action attribute on the form. wget is a stand in for whatever scripting language you choose's basic HTML operator object. In the case of Python that would be urllib2. Since you're familiar with Javascript already, perhaps look at Node.js?

If GET calls don't work, you can also craft POST calls but that usually involves a little more language-dependent frippery but the concept is the same.
posted by Fezboy! at 1:48 PM on November 14, 2014

If your desired end product is a bunch of PDFs on your own computer, why is this going through a web form at all? Just set up a mail merge in Word, format it to look like your end product, and use your spreadsheet as the data source. Print to PDF. Done.

This will probably wind up printing to a single multi-page PDF, so you'll need to split that into separate documents, but there are ways of doing that too.
posted by adamrice at 2:42 PM on November 14, 2014

« Older Take me on a tour of words, to places you remember   |   Tips on planning the perfect disneyland trip on a... Newer »
This thread is closed to new comments.