GrabzIt
Tools to Capture and Convert the Web

How do you take a screenshot from behind a login?

Most screenshot services do not support taking screenshots behind a login, however to enable this we have opened up the ability to set cookies in GrabzIt. As websites often use cookies to identify a user, if you assign the users session cookie to GrabzIt all the users session data will be available when any screenshots are taken.

GrabzIt provides two main ways of doing this via a login web service or by specifying your own session cookie.

Automatically create login cookies

  • Warning this feature is currently in beta and may not provide consistent results.

The login web service requires the form URL to submit too, along with any required form parameters, and your application key. After the web service executes any cookies are automatically saved to your account. Now when you take a screenshot of a webpage on the same domain these cookies will be used. An example of a login form to submit to is shown below.

<form action="login.php" method="post">
   <div class="FormRow">
      <label>Username</label>
      <input type="text" name="username" value="">
   </div>
   <div class="FormRow">
      <label>Password</label>
      <input type="password" name="password" value="">
   </div>
   <input type="submit" class="submit" value="Login">
</form>
Remember to URL encode every parameter value!

The login web service has the following format. You must specify the URL the form is being submitted to, your application key and all of the form parameters you want to submit.

Note that we do not store any of the login details you pass to us for your security.

https://api.grabz.it/services/login.ashx?key=Sign in to view your Application Key&formurl=[URL of the form]&
[form parameter one]=[form value one]&[form parameter two]=[form value two]&[form parameter ...]=[form value ...]

Below is an example of how to submit to the above login form.

https://api.grabz.it/services/login.ashx?key=Sign in to view your Application Key&formurl=http://www.example.com/login.php
&username=joebloggs&password=12345

This call will return XML detailing all of the cookies that where saved to your account by this action. For the login to be successful the target websites session cookie must be listed, if it is you can now create captures of the web pages that require a logged in user.

Specify all of a user's session cookies

If you specify all of the user's session cookies then when you create a capture of a secure web page GrabzIt will create a capture as the user would see it, this is very useful if you want to do things like capture a report in a user's dashboard etc. To do this you need to use a server-side language as JavaScript won’t have access to the HTTP only cookies often associated with a user's session cookies.

To do this pass the all of the cookies involved in a user’s session using the SetCookie method.

$sessionValue = $_COOKIE['PHPSESSID'];
$grabzIt->SetCookie('PHPSESSID', 'example.com', $sessionValue);
$grabzIt->URLToImage('http://example.com/dashboard.php');
$grabzIt->Save('http://example.com/handler.php');

In this example we are assuming there is only one cookie involved in the user's session called PHPSESSID, however there could be more than one and could be named differently. It all depends on how you have created your website. Developer ToolsOne way to debug any cookie issues, by signing into the target website and use the browsers built in developer tools, to do this in the Chrome browser just press F12. Then identify the websites session cookie and add name, domain and value of this cookie to GrabzIt by using the custom cookies page, it is a good idea to use a expiration date a long time in the future to ensure the session cookie is not deleted.

Capture the HTML

Use our JavaScript API to send us the HTML of the web page that is behind the login. As long as none of the web page resources, such as CSS, JavaScript and images, are referenced with absolute URL's or embedded in the web HTML and are not restricted by website security it should capture the users web page correctly as shown in this example.

Post to a login form

This login method will only work if the web page you want to capture is the web page directly after the login screen or if the website provides a redirect URL that the browser will follow after login is complete.

Specify Basic Authentication Credentials

Some web pages use basic authentication were the browser asks the user to authenticate themselves before displaying the page. GrabzIt enables you to screenshot these web pages by specifying your basic authentication credentials.

Back to SupportMore Web Capture ArticlesCommunity Web Capture Questions
Try all our premium features for free with a 7 day free trial. Then from $5.99 a month, unless cancelled.
  • More Captures
  • More Features
  • More API's
  • Bigger Scrapes
  • Bigger Captures
  • Bigger Everything
Start Free Trial