Custom POST Data, Referer and Cookie

Custom POST Data:

You can customize the request which is sent to the target page for the screenshot. You can include any POST Data, like you were sending a form. This pages shows hot to use the feature from Browshot.

For example, let us say you would like to take a screenshot of your Browshot dashboard at "". In order to access this page, you must be logged in. To login, you can fill out the form at "" with your username and password, and you will be redirected to your dashboard. Browshot support redirections, so this is fine.

Let us say your username is foo and password is bar. You need to pass this value to post_data:


If you use any of the Browshot libraries, you do not need to worry about encoding data:

$browshot->create_screenshot(url => '', post_data => 'username=foo&password=bar'); # Full API, Perl
$browshot->simple(url => '', post_data => 'username=foo&password=bar'); # Simple API, Perl
client.screenshot_create('', { 'post_data' => 'username=foo&password=bar' }); # Full API, Ruby
client.simple('', { 'post_data' => 'username=foo&password=bar' }); # Simple API, Ruby

However, if you prefer to use the command line to get a screenshot, you need to take care of encoding the post_data value correctly: & becomes %26, = becomes %3d, etc.:

wget "" -O /tmp/dashboard.png

Custom Referer:

Similarly, you can define a custom Referer header. Some websites display different content if the user comes from a search engine, or redirect users to the home page is they do not come from the same site.

Like for the post_data parameter, you need to encode the Referer URL if you use the command line.

If you want to simulate a request by a user coming from a Google search for "test screenshot", you can use the Refer Using wget, it looks like this:

wget "" -O /tmp/search.png

Custom Cookie:

You can use a custom cookie string, for example to reuse an existing session. The cookie is set for the URL of the target site.

The cookie string can contain several key=value pairs.

Like for the post_data and referer parameters, you need to encode the cookie string if you use the command line.


Sign up for a free account