CSS Scraper
The CSS Scraper reads an asset's price from any public web page, using a CSS selector that points at the number. Use it when no other provider covers the instrument. In the Provider list it is called CSS Web Scraper.
๐ What It Offers
- โ Current price: read from the page at every sync, in the currency you choose.
- โ History: none. Each sync saves the day's price, so the history grows from the day you start.
- โ Search and details: none โ you enter the page address and the settings yourself.
๐งฉ Set It Up
1๏ธโฃ Copy the Price's CSS Selector
The selector tells LibreFolio which element of the page holds the price.
- Open the page and right-click the price.
- Choose Inspect (or press
F12): DevTools highlights the price element. - Right-click the highlighted element, then Copy โ Copy selector.
- Open the page and right-click the price.
- Choose Inspect (or press
F12): the Inspector highlights the price element. - Right-click the highlighted element, then Copy โ CSS Selector.
2๏ธโฃ Fill In the Provider Settings
In Provider Assignment, choose CSS Web Scraper and paste the page address into URL. The settings appear under their technical names:
| Setting | Required | What to enter |
|---|---|---|
current_css_selector |
โ | The selector you copied, e.g. .summary-value strong |
currency |
โ | The currency of the price, e.g. EUR |
decimal_format |
โ | us for 1,234.56 (the default) or eu for 1.234,56 |
timeout |
โ | Seconds to wait for the page (default 30) |
user_agent |
โ | How LibreFolio introduces itself to the site (default LibreFolio/1.0) |
3๏ธโฃ Test It
Click Test Configuration: Current Price must show the number you see on the page. The โ ๏ธ on History is expected, as this provider has none.
A BTP on Borsa Italiana
- URL:
https://www.borsaitaliana.it/borsa/obbligazioni/mot/btp/scheda/IT0005634800.html?lang=en current_css_selector:.summary-value strongcurrency:EURdecimal_format:usโ the English page shows100.39. The Italian page (lang=it) shows100,39, so there useeu.
For instruments listed on Borsa Italiana, the Borsa Italiana provider also brings their history.
๐ ๏ธ Troubleshooting
| What you see | What to do |
|---|---|
| Price element not found | The page layout may have changed: copy the selector again. |
| Failed to parse price | Check decimal_format. The element must hold just the number: spaces, โฌ, $, ยฃ, ยฅ and % are ignored, letters such as EUR are not. |
| HTTP error or Request failed | Check the URL; raise timeout for a slow site. Error 403 means the site refuses automated visits. |
| A wrong number | The selector matches another element (LibreFolio uses the first match): make it more specific. |
โ ๏ธ Limits
- LibreFolio reads the page as the site sends it, without running its scripts: a price filled in by JavaScript cannot be read, nor can pages behind a login.
- When the site changes its layout, the selector may stop matching: test again and copy a new one.
๐ Related
- โ๏ธ Data Editor โ Enter or correct prices by hand
- ๐ ๏ธ For developers: CSS Scraper Provider โ Request, parsing and error codes