Skip to content

JavaScript Rendering

All these features are working with the js_render parameter set to true.

Block Resources

Blocking resources means preventing your headless browser from downloading specific types of content that you don’t need for your scraping task. This can include images, stylesheets, fonts, and other elements that might not be essential for your data extraction.

Available Resource Types

BitFetcher allows you to block the following resource types:

Resource TypeDescription
stylesheetCSS files for page styling.
imageImages, icons, and banners.
mediaAudio and video files.
fontWeb fonts for text styling.
scriptJavaScript files.
xhrAJAX requests via XMLHttpRequest.
fetchFetch API requests.
eventsourceServer-sent events requests.
websocketWebSocket connections.
manifestWeb app metadata files.
otherMiscellaneous resource types.

To block multiple resources, separate them with commas. For example, to block images and stylesheets, use block_resources=image,stylesheet.

Screenshots

If you want to get a screenshot of the page you want to scrape, use the screenshot=true parameter. By default, the image will be in PNG format.

Optional Parameters

  • screenshot_fullpage=true takes a full-page screenshot.
  • screenshot_selector=<CSS Selector> takes a screenshot of the element given in the CSS Selector.

These screenshot features can be combined with other options like wait, wait_for, or js_scenario to ensure that the page or elements are fully loaded before capturing the image. When using json_response, the result will include a JSON object Screenshot with the screenshot data encoded in base64, allowing for easy integration into your workflows.

Screenshot Formats

In addition to the basic screenshot functionality, offers customization options to optimize the output. These features are particularly useful for reducing file size, especially when taking full-page screenshots where the image might exceed 10MB, causing errors.

  • screenshot_format: Choose between png and jpeg formats, with PNG being the default. PNG is great for high-quality images and transparency, while JPEG offers efficient compression.
  • screenshot_quality: Applicable when using JPEG, this parameter allows you to set the quality from 1 to 100. Useful for balancing image clarity and file size, especially in scenarios where storage or bandwidth is limited.