Giter Site home page Giter Site logo

html-metadata-parser's Introduction

Html Metadata Parser

Html Metadata scraper and parser for Node.js

Install

npm install html-metadata-parser
yarn install html-metadata-parser
const { parser } = require('html-metadata-parser');

parser('https://www.youtube.com/watch?v=eSzNNYk7nVU').then(result=>{
   console.log(JSON.stringify(result, null, 3));
})
// async 
const { parser } = require('html-metadata-parser');
(async () => {
    var result = await parse('https://www.youtube.com/watch?v=eSzNNYk7nVU');
    console.log(JSON.stringify(result, null, 3));
})();
// result

{
   "og": {
      "site_name": "YouTube",
      "url": "https://www.youtube.com/watch?v=eSzNNYk7nVU",
      "title": "Rebuilding iOS 15 with Tailwind CSS",
      "image": "https://i.ytimg.com/vi/eSzNNYk7nVU/maxresdefault.jpg",
      "description": "In this video, I'll show you how to rebuild the new Notification Summary UI from iOS 15 using Tailwind CSS.Source code: https://play.tailwindcss.com/kY4LYXwsNZ",
      "type": "video.other"
   },
   "meta": {
      "title": "Rebuilding iOS 15 with Tailwind CSS",
      "description": "In this video, I'll show you how to rebuild the new Notification Summary UI from iOS 15 using Tailwind CSS.Source code: https://play.tailwindcss.com/kY4LYXwsNZ"
   },
   "images": []
}

15 Best Visual Studio Code Themes of 2021

What is the difference between PM2 Cluster vs Fork Mode

Lightbox Photo Grid and Slideshow component for Vue.JS?

Contributing

Please refer to each project's style and contribution guidelines for submitting patches and additions. In general, we follow the "fork-and-pull" Git workflow.

  1. Fork the repo on GitHub
  2. Clone the project to your own machine
  3. Commit changes to your own branch
  4. Push your work back up to your fork
  5. Submit a Pull request so that we can review your changes

NOTE: Be sure to merge the latest from "upstream" before making a pull request!

Community

Stay up to date on the development of Morioh UI and reach out to the community with these helpful resources.

Follow @codek_tv and @im_a_developer on Twitter.

Follow Morioh and Javascript Developers on FaceBook.

Join the official Discord room: https://discord.gg/sqxU6un.

html-metadata-parser's People

Contributors

nasa8x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

html-metadata-parser's Issues

Error when fetching meta data

I am building a service that requires me to fetch metadata from any given URL.
This isn't at the center of what I am working on, it's an addon feature and after some Google search I found this package (cool stuff)

When working with most URLs and fetching data everything seems to work fine.
But whenever I try to retrieve metadata from http://web.com, it throws an error.

Initially thought it was an issue from my setup, but I tried it on Runkit and the same issue occurs.
Is there a Good reason for this?

Attached is a link to what happens
https://scrnli.com/uqKqh195WJa3b8

Also attached is a link to the expected output
https://scrnli.com/WFfk2P1WPjdA7v

TypeScript: metadata.images incorrectly reported as string[]

When using html-metadata-parser in VS Code I get Metadata.images?: string[] | undefined whereas Metadata.images really is an Array of { src: String } objects.

I tried to look in https://github.com/nasa8x/html-metadata-parser/blob/master/src/index.ts but couldn't find the error.

My workaround:

interface MetadataImage {
  src: string
}

const metadata = await htmlMetadataParser(url)
const metadataImages = metadata.images as unknown as MetadataImage[]

Parsing existing HTML?

Are you open to PRs? If so, I'd like to add the utility to parse existing HTML returned other HTTP libraries to get meta tag information

const Meta = require('html-metadata-parser');

Meta.parseHtml(`<meta name="author" content="John Doe">`, (err, res) => {
    // handle r es
})

Add data-src support and fix url regex check

Some IMG tags only have data-src attributes when axios returns the HTML data. It will be nice to also have data-src support.

Also, the regex check for URL returns false for https://c. and it is supposed to be true.

Looking to create a PR

Support for Twitter

I was trying to parse a link but I only get a response of the link that was passed.

parser(link).then((result: unknown) => {
console.log("RESULT: ", result);
})

"RESULT": { "meta": { "url": "https://twitter.com/foo/status/bar" }, "og": { "site_name": "Twitter" }, "images": [] }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.