2

I'm working on an open source library, but some of the functionality requires that I emulate a browser. I hear it's possible to launch an instance of the browser, but if I'm running on linux, I don't think all browsers will be available, and vice versa, safari wouldn't be available on anything but a Mac. So is there a browser emulator that sys admins here know of, preferably something open source because I'm working on open source code.

Any possible solutions I'm overlooking?

Please forgive me if I'm not upvoting helpful answers. My rep is below the level required to upvote. But thank you nonetheless.

park
  • 33
  • 1
  • 4
  • possible duplicate of http://stackoverflow.com/questions/2073481/headless-scriptable-firefox-webkit-on-linux – ephemient Dec 05 '10 at 04:28
  • @ephemient, well, if I want to render the data to a png like OneOfOne suggests, then that method wouldn't work. Would it? – park Dec 05 '10 at 04:49
  • can you be more specific? do you want browser code to manipulate cookies? run javascript? automate form submissions? – Brad Clawsie Dec 05 '10 at 05:01
  • @brad, For starters, I'd want to take a screenshot to a png. – park Dec 05 '10 at 05:14
  • take a screenshot of what? many sites require javascript to be run for the page to render. – Brad Clawsie Dec 05 '10 at 06:53
  • @park: Tried [khtml2png](http://khtml2png.sourceforge.net/)? It uses the KHTML browser engine to render the page to a file, supporting many formats including PNG. You could certainly take a look at it to get an idea how this is done. – Sorpigal Dec 06 '10 at 18:06

2 Answers2

3

Have you looked at Selenium?

Thiago Figueiro
  • 830
  • 1
  • 6
  • 18
1

Well, you can always embed a browser in your code, like WebKit (Qt4), there are ports to almost all languages.

Also in recent linux distros you can do xdg-open http://url to open the default browser.

You can use webkit to render the data to a png or such.

OneOfOne
  • 222
  • 4
  • 13