3

Google, Facebook and some others now have a preview link functionality where you can view a "screenshot" of say a website's home page. Are there any suggestions how I can achieve this?

Specifically I'd like to be able to grab a screenshot (a la iPhone screen shot) and make it available as an image such as a jpg or png.

I want to do this from python if possible.

Marcel Korpel
  • 21,536
  • 6
  • 60
  • 80
David Kierans
  • 1,599
  • 1
  • 16
  • 24

3 Answers3

3

For that you have to run a separate web browser and then save the image in the required format. You may try a headless web stack like phantomJS as a separate process and capture its out put as image.

There are several web services that provide this functionality like WebSnapr

suhair
  • 10,895
  • 11
  • 52
  • 63
  • Thanks for that. I was thinking that this (phantomJS) might be a way to try but if somebody else has done the work I'll happily use that. Websnapr looks good but I have to get it to work sensible with iPhone sizing. – David Kierans Apr 27 '11 at 01:03
  • Update: I ended up using phantomjs to do this. A few things to look out for though: We had to work through a few issues to get a reasonable render time. The dependencies for this are ridiculous to the extreme - QT & X window dependencies. All things considered the screenshots are perfect and rendered in fractions of a second locally. If anybody is interested in the details drop me a line. – David Kierans May 12 '11 at 15:35
2

We're using the service Bluga, it's not too expansive and is pretty easy to implement. If you don't like that there are many other services available.

Markus Hedlund
  • 23,374
  • 22
  • 80
  • 109
  • Thanks. Tried out Bluga which was easy to use but too slow for my immediate use as I need a bit now realtime so to speak. Checking out the alternatives now as well. – David Kierans Apr 27 '11 at 01:22
  • I don't think you will find anything realtime, there are too much processing to capture a screenshot. The service will have to put your request in a queue, a screenshot drone will have to load the website, take the screenshot, save it and send it/the link to you. – Markus Hedlund Apr 27 '11 at 11:51
  • Update: I ended up using phantomjs to do this. A few things to look out for though: We had to work through a few issues to get a reasonable render time. The dependencies for this are ridiculous to the extreme - QT & X window dependencies. All things considered the screenshots are perfect and rendered in fractions of a second locally. If anybody is interested in the details drop me a line. – David Kierans May 12 '11 at 15:34
  • @znarkus yes it will capture flash. You need to set load-plugins=yes . I have not had the need and my environment was Linux. I have read anecdotal evidence of it being a bit inconsistant on windows but I'd guess if it worked at all on windows then tit might be just timing issues. – David Kierans May 16 '11 at 05:57
0

Jquery Preview may also help. It is really similar to Facebook's preview

Thellimist
  • 3,757
  • 5
  • 31
  • 49