Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wileylabs/data-block-extract
Extract content from HTML data block script elements
https://github.com/wileylabs/data-block-extract
data-block experiment html html5 json-ld
Last synced: 2 days ago
JSON representation
Extract content from HTML data block script elements
- Host: GitHub
- URL: https://github.com/wileylabs/data-block-extract
- Owner: WileyLabs
- License: mit
- Created: 2018-10-17T20:49:23.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-25T15:29:31.000Z (almost 3 years ago)
- Last Synced: 2023-03-04T04:05:20.288Z (almost 2 years ago)
- Topics: data-block, experiment, html, html5, json-ld
- Language: JavaScript
- Size: 29.3 KB
- Stars: 1
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# HTML5 data block extractor
Did you know you can embed "raw" data into an HTML `` tag? The HTML5
spec calls them [data blocks](https://www.w3.org/TR/html5/semantics-scripting.html#data-block).They look like this...
```html
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"type": "SoftwareApplication",
"name": "data block extractor",
"alternateName": "data-block-extractor"
}```
This little command-line script takes a URL or a file, and extracts the content
from any data blocks found in that file.Currently, it just dumps them to standard out and only looks for
`application/ld+json`, but it's a start anyway!## Install
For now, you have to `npm i -g` from inside a clone of this repository. At
somepoint, we'll get this up on NPM for easier re-use.However, once you've done that, you can run `data-block-extractor` anywhere to
use this awesomeness!## Usage
```sh
$ data-block-extract http://bestbuy.com/
```Three results are (currently) found at [BestBuy](http://bestbuy.com/), which
looks like this in the output:
```
{"@context" : "http://schema.org","@type" : "WebSite","name" : "Best Buy","url" : "http://www.bestbuy.com/"}{"@context": "http://schema.org","@type": "Organization","name": "Best Buy","url": "http://www.bestbuy.com/","sameAs": ["http://www.facebook.com/bestbuy","https://twitter.com/BestBuy","https://plus.google.com/+BestBuy","https://www.instagram.com/bestbuy/","https://www.youtube.com/user/bestbuy","https://www.linkedin.com/company/best-buy","https://pinterest.com/BestBuy"],"contactPoint": [{"@type": "ContactPoint","telephone": "+1-888-237-8289","contactType": "customer service","contactOption": "TollFree","availableLanguage": ["English","Spanish"]}, {"@type": "ContactPoint","telephone": "+1-888-574-1301","contactType": "credit card support","contactOption": "TollFree","availableLanguage": ["English","Spanish"]}]}
{"@context":"http://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"https://www-ssl.bestbuy.com/","name":"Best Buy"}}]}
```At the moment there is no additional parsing, but that's coming!
## License
MIT