Script to take web survey for me
Asked Answered
S

3

0

I had to take a surveymonkey survey today, and the format was as follows: a question was asked, then after hitting the next button, the answer was displayed as "Answer: _" along with an explanation. For kicks, I'd like to make a program that could take this survey, answering any letter, then going to the next page and reading the answer, then going back and changing the answer to the correct one, then going 2 pages ahead and repeating.

I am familiar with Java and Python, but I'm not sure how to make them be able to "know" where the button is, and how to "read" text without unnecessary image recognition.

This is just a fun project, nothing serious, but I would appreciate any ideas to get me started.

Seaborne answered 1/9, 2009 at 19:42 Comment(0)
B
1

Assuming that the text was just that (text rather than images), there are a few useful tools for you:

  • .Net WebControl - I've scripted this before from .Net. It has the advantage of making all of the JS on the page still work. I know this isn't Java, but it is surprisingly easy to work with for this kind of task.
  • Selenium - It is primarily a web testing framework, but it would be easy to script it from Java to auto-submit forms.
  • TagSoup for Java - If the pages do not have significant javascript code that needs to run, there are many HTML parsers for Java that could potentially be used to develop a scraper.
Bhopal answered 1/9, 2009 at 19:48 Comment(0)
S
0

Would it be unrealistic to make it post to the survey monkey pages? You could then do some regex's to pull "answer:__" out and look for that pattern in the original page. It would definitely be easier than trying to click things in a browser, etc. Basically, write a java app or python for that matter that does http posts to the survey pages in order and uses regex's to find the next page, etc and then use a stack to keep track of the history.

Edit if this isn't clear, let me know, I'll clarify

Edit 2: I completely forgot about HTMLUnit, my bad. It is a testing framework like suggested by jsight but specifically for Java and functions very similarly to JUnit, however, because it is designed for testing web applications, it can be used to automate interactions with other sites

Sutherland answered 1/9, 2009 at 19:47 Comment(0)
D
-1

You can do it using a simple image search. First screenshot the a unique part of the button and save it. This will be used as the relative reference on where you click the mouse. Then during the actual running of the application, have a screenshot of the entire screen and find a part matching the previously saved image and then let the mouse click on the appropriate location based on the button image location.

Dmitri answered 8/2, 2013 at 21:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.