Julien Sobrier > WebService-Browshot-1.11.0 > WebService::Browshot

Download:
WebService-Browshot-1.11.0.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.11.0   Source   Latest Release: WebService-Browshot-1.14.0

NAME ^

WebService::Browshot - Perl extension for Browshot (http://www.browshot.com/), a web service to create website screenshots.

SYNOPSIS ^

  use WebService::Browshot;
  
  my $browshot = WebService::Browshot->new(key => 'my_key');
  my $screenshot = $browshot->screenshot_create(url => 'http://www.google.com/');
  [...]
  $browshot->screenshot_thumbnail_file(id => $screenshot->{id}, file => 'google.png');

DESCRIPTION ^

Browshot (http://www.browshot.com/) is a web service to easily make screenshots of web pages in any screen size, as any device: iPhone, iPad, Android, Nook, PC, etc. Browshot has full Flash, JavaScript, CSS, & HTML5 support.

The latest API version is detailed at http://browshot.com/api/documentation. WebService::Browshot follows the API documentation very closely: the function names are similar to the URLs used (screenshot/create becomes screenshot_create(), instance/list becomes instance_list(), etc.), the request arguments are exactly the same, etc.

The library version matches closely the API version it handles: WebService::Browshot 1.0.0 is the first release for the API 1.0, WebService::Browshot 1.1.1 is the second release for the API 1.1, etc.

WebService::Browshot can handle most the API updates within the same major version, e.g. WebService::Browshot 1.0.0 should be compatible with the API 1.1 or 1.2.

The source code is available on github at https://github.com/juliensobrier/browshot-perl.

METHODS ^

new()

  my $browshot = WebService::Browshot->new(key => 'my_key', base => 'http://api.browshot.com/api/v1/', debug => 1]);

Create a new WebService::Browshot object. You must pass your API key (go to you Dashboard to find your API key).

Arguments:

key

Required. API key.

base
 Optional. Base URL for all API requests. You should use the default base provided by the library. Be careful if you decide to use HTTP instead of HTTPS as your API key could be sniffed and your account could be used without your consent.
debug

Optional. Set to 1 to print debug output to the standard output. 0 (disabled) by default.

timeout

Optional. Set the request timeout - in seconds - against the API. Defaults to 90s.

last_error contasin the last error message, it is NEVER reset, i.e last_error may not be empty after a succesfull API call if an earlier call failed.

api_version()

Return the API version handled by the library. Note that this library can usually handle new arguments in requests without requiring an update.

simple()

   $browshot->simple(url => 'http://mobilito.net')

Retrieve a screenshot in one function. Note: by default, screenshots are cached for 24 hours. You can tune this value with the cache=X parameter.

Return an array (status code, PNG). See http://browshot.com/api/documentation#simple for the list of possible status codes.

Arguments:

See http://browshot.com/api/documentation#simple for the full list of possible arguments.

url

Required. URL of the website to create a screenshot of.

simple_file()

   $browshot->simple_file(url => 'http://mobilito.net', file => '/tmp/mobilito.png')

Retrieve a screenshot and save it locally in one function. Note: by default, screenshots are cached for 24 hours. You can tune this valu with the cache=X parameter.

Return an array (status code, file name). The file name is empty if the screenshot was not retrieved. See http://browshot.com/api/documentation#simple for the list of possible status codes.

Arguments:

See http://browshot.com/api/documentation#simple for the full list of possible arguments.

url

Required. URL of the website to create a screenshot of.

file

Required. Local file name to write to.

instance_list()

Return the list of instances as a hash reference. See http://browshot.com/api/documentation#instance_list for the response format.

instance_create()

Create a private instance. See http://browshot.com/api/documentation#instance_create for the response format.

instance_info()

   $browshot->instance_info(id => 2)

Return the details of an instance. See http://browshot.com/api/documentation#instance_info for the response format.

Arguments:

id

Required. Instance ID

browser_list()

Return the list of browsers as a hash reference. See http://browshot.com/api/documentation#browser_list for the response format.

browser_info()

   $browshot->browser_info(id => 2)

Return the details of a browser. See http://browshot.com/api/documentation#browser_info for the response format.

Arguments:

id

Required. Browser ID

browser_create()

Create a custom browser. See http://browshot.com/api/documentation#browser_create for the response format.

screenshot_create()

  $browshot->screenshot_create(url => 'http://wwww.google.com/', instance_id => 3, size => 'page')

Request a screenshot. See http://browshot.com/api/documentation#screenshot_create for the response format. Note: by default, screenshots are cached for 24 hours. You can tune this valu with the cache=X parameter.

Arguments:

See http://browshot.com/api/documentation#screenshot_create for the full list of possible arguments.

url

Required. URL of the website to create a screenshot of.

instance_id

Optional. Instance ID to use for the screenshot.

size

Optional. Screenshot size.

screenshot_info()

  $browshot->screenshot_info(id => 568978)

Get information about a screenshot requested previously. See http://browshot.com/api/documentation#screenshot_info for the response format.

Arguments:

id

Required. Screenshot ID.

screenshot_list()

  $browshot->screenshot_list(limit => 50)

Get details about screenshots requested. See http://browshot.com/api/documentation#screenshot_list for the response format.

Arguments:

limit

Optional. Maximum number of screenshots to retrieve.

screenshot_host()

  $browshot->screenshot_host(id => 12345, hosting => 'cdn')

Host a screenshot or thumbnail. See http://browshot.com/api/documentation#screenshot_host for the response format.

Arguments:

id

Required. Screenshot ID.

screenshot_thumbnail()

  $browshot->screenshot_thumbnail(id => 52942, width => 500)

Retrieve the screenshot, or a thumbnail. See http://browshot.com/api/documentation#screenshot_thumbnail for the response format.

Return an empty string if the image could not be retrieved.

Arguments:

See http://browshot.com/api/documentation#screenshot_thumbnail for the full list of possible arguments.

id

Required. Screenshot ID.

width

Optional. Maximum width of the thumbnail.

height

Optional. Maximum height of the thumbnail.

screenshot_thumbnail_file()

  $browshot->screenshot_thumbnail_file(url => 'https://ww.browshot.com/screenshot/image/52942?key=my_key', height => 500, file => '/tmp/google.png')

Retrieve the screenshot, or a thumbnail, and save it to a file. See http://browshot.com/api/documentation#thumbnails for the response format.

Return an empty string if the image could not be retrieved or not saved. Returns the file name if successful.

Arguments:

See http://browshot.com/api/documentation#thumbnails for the full list of possible arguments.

url
 Required. URL of the screenshot (screenshot_url value retrieved from C<screenshot_create()> or C<screenshot_info()>). You will get the full image if no other argument is specified.
file

Required. Local file name to write to.

width

Optional. Maximum width of the thumbnail.

height

Optional. Maximum height of the thumbnail.

screenshot_share()

  $browshot->screenshot_share(id => 12345, note => 'This is my screenshot')

Share a screenshot. See http://browshot.com/api/documentation#screenshot_share for the response format.

Arguments:

id

Required. Screenshot ID.

note

Optional. Public note to add to the screenshot.

screenshot_delete()

  $browshot->screenshot_delete(id => 12345, data => 'url,metadata')

Delete details of a screenshot. See http://browshot.com/api/documentation#screenshot_delete for the response format.

Arguments:

id

Required. Screenshot ID.

data

Optional. Information to delete.

account_info()

Return information about the user account. See http://browshot.com/api/documentation#account_info for the response format.

CHANGES ^

1.11

Compatible with API 1.11. Option HTTP timeout.

1.10

Add screenshot_delete for API 1.10.

1.9.4

Fix status code in error messages.

1.9.3

Keep backward compatibility for screenshot_thumbnail.

1.9.0

Add screenshot_share for API 1.9.

1.8.0

Update screenshot_thumbnail to use new API.

1.7.0

Update screenshot_info to handle additional parameters

1.5.1

Use binmode to create valid PNG files on Windows.

1.4.1

Fix URI encoding.

1.4.0

Add simple and simple_file methods.

1.3.1

Retry requests (up to 2 times) to browshot.com in case of error

SEE ALSO ^

See http://browshot.com/api/documentation for the API documentation.

Create a free account at http://browshot.com/login to get your free API key.

Go to http://browshot.com/dashboard to find your API key after you registered.

AUTHOR ^

Julien Sobrier, <julien@sobrier.net>

COPYRIGHT AND LICENSE ^

Copyright (C) 2012 by Julien Sobrier

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: