0

I am trying to automate the querying of names on 2 different websites. For each website I have to enter in the same name and take a screenshot of the results.I don't know how to approach this project. Is it possible to automate this with a javascript? Thank you for any input.

Website links are below:

[1] http://exclusions.oig.hhs.gov/search.aspx

[2] http://www.health.ny.gov/professionals/doctors/conduct/license_lookup.htm

vinczemarton
  • 7,756
  • 6
  • 54
  • 86
Kevin Johnson
  • 51
  • 2
  • 9
  • possible duplicate of [Javascript to take a screenshot of a website without using ActiveX](http://stackoverflow.com/questions/2046812/javascript-to-take-a-screenshot-of-a-website-without-using-activex) – Marc B Feb 01 '12 at 20:51
  • Yes, but now with JavaScript. You need to do this on a server. – Diodeus - James MacFarlane Feb 01 '12 at 20:52
  • I added the java tag because I had figured it may not be possible to be done in javascript. Which Diodeus has confirmed. How would I accomplish this on a server? – Kevin Johnson Feb 01 '12 at 21:01
  • There are a lot of jaw-dropping javascript libraries nowadays. Check out Jesse's answer. Or http://hertzen.com/experiments/jsfeedback/ if canvas is an option. And if you want to do it on the server-side, you should describe your framework. – vinczemarton Feb 02 '12 at 07:32

2 Answers2

0

You should be able to accomplish this with PhantomJS relatively easily. Check out the examples page - you'll probably want to use code evaluation to fill out and submit your forms, after which you can render the page to an image file.

Jesse Fulton
  • 2,188
  • 1
  • 23
  • 28
0

You actually do this is one step: send a POST requests to the information you need. For the first example, you would send these POST data:

__VIEWSTATE=dDwtNzQ5MzEyMDI3Ozs%2BHWC8LXZfQQTCTJWtmudNLStjn%2Fk%3D&txtLastName1=test&txtFirstName1=&txtBusinessName1=&txtLastName2=&txtFirstName2=&txtBusinessName2=&txtLastName3=&txtFirstName3=&txtBusinessName3=&txtLastName4=&txtFirstName4=&txtBusinessName4=&txtLastName5=&txtFirstName5=&txtBusinessName5=&cmdSubmit=Search

So you can use PhantomJS, as suggested, with a POST request and take a screenshot. Or you can use a web service to create the screenshots. Unfortunately, very few allow POST requests with custom POST data. Browshot (see API) lets you send POST data and use a custom Referer. So your screenshot requests would include (after you encode the POST data):

url=http://exclusions.oig.hhs.gov/search.aspx&referer=http://exclusions.oig.hhs.gov/search.aspx&post_data=__VIEWSTATE%3DdDwtNzQ5MzEyMDI3Ozs%252BHWC8LXZfQQTCTJWtmudNLStjn%252Fk%253D%26txtLastName1%3Dtest%26txtFirstName1%3D%26txtBusinessName1%3D%26txtLastName2%3D%26txtFirstName2%3D%26txtBusinessName2%3D%26txtLastName3%3D%26txtFirstName3%3D%26txtBusinessName3%3D%26txtLastName4%3D%26txtFirstName4%3D%26txtBusinessName4%3D%26txtLastName5%3D%26txtFirstName5%3D%26txtBusinessName5%3D%26cmdSubmit%3DSearch

I have tested it, and do get a screenshot of the results, like if I filled out the form and submitted it.

Julien
  • 5,729
  • 4
  • 37
  • 60
  • When I use the url "http://exclusions.oig.hhs.gov/search.aspx&referer=http://exclusions.oig.hhs.gov/search.aspx&post_data=__VIEWSTATE%3DdDwtNzQ5MzEyMDI3Ozs%252BHWC8LXZfQQTCTJWtmudNLStjn%252Fk%253D%26txtLastName1%3Dtest%26txtFirstName1%3D%26txtBusinessName1%3D%26txtLastName2%3D%26txtFirstName2%3D%26txtBusinessName2%3D%26txtLastName3%3D%26txtFirstName3%3D%26txtBusinessName3%3D%26txtLastName4%3D%26txtFirstName4%3D%26txtBusinessName4%3D%26txtLastName5%3D%26txtFirstName5%3D%26txtBusinessName5%3D%26cmdSubmit%3DSearch" I am getting a Bad Request (Invalid URL) error. Any ideas? – Kevin Johnson Feb 24 '12 at 16:31