Single element or list
By default, we will return you the first HTML element that matches the selector. If you want to get all elements matching the selector, you should use the type option.
type: item | list (default: item)
- item: Return first element matching the selector (default)
- list: Return a list of all elements matching the selector
Example
Here is an example for extracting post titles from our blog:
JSON
1{2"extract_rules": {3"first_post_title": {4"selector": ".post-title",5"type": "item"6},7"all_post_title": {8"selector": ".post-title",9"type": "list"10}11}12}
The information extracted by the above rules on FoxScrape's blog page would be:
JSON
1{2"first_post_title": " Block ressources with Puppeteer - (5min)",3"all_post_title": [4" Block ressources with Puppeteer - (5min)",5" Web Scraping vs Web Crawling: Ultimate Guide - (10min)",6"...",7" Scraping E-Commerce Product Data - (6min)",8" Introduction to Chrome Headless with Java - (4min)"9]10}