How to remove any element from the HTML response

Sometimes you may need to remove specific HTML elements from the page's content, either to get cleaner results for your data extraction rules, or to simply delete unnecessary content from your response.

To achieve that using ScrapingBee, you can use aJavaScript Scenario, with an evaluate instruction and execute this custom JS code:

document.querySelectorAll("ELEMENT-CSS-SELECTOR").forEach(function(e){e.remove();});​

For example, to remove all of the <style> elements from the response, you can use this JavaScript Scenario:

{"instructions": [{"evaluate": 'document.querySelectorAll("style").forEach(function(e){e.remove();});'}]}
Go back to tutorials