metascraper | Get unified metadata from websites using Open Graph | Scraper library
kandi X-RAY | metascraper Summary
kandi X-RAY | metascraper Summary
A library to easily scrape metadata from an article on the web using Open Graph, JSON+LD, regular HTML metadata, and series of fallbacks.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of metascraper
metascraper Key Features
metascraper Examples and Code Snippets
export default {
serverMiddleware: [
{ path: '/api/meta-scraper', handler: '~/api/meta-scraper.js' }
]
}
export default function (req, res, next) {
// req is the Node.js http request object
console.log(
Community Discussions
Trending Discussions on metascraper
QUESTION
const metascraper = require('metascraper')([
require('metascraper-author')(),
require('metascraper-date')(),
require('metascraper-description')(),
require('metascraper-image')(),
require('metascraper-logo')(),
require('metascraper-clearbit')(),
require('metascraper-publisher')(),
require('metascraper-title')(),
require('metascraper-url')()
])
...ANSWER
Answered 2022-Feb-04 at 01:41The following should work:
QUESTION
I want to make a simple wishlist with nuxt (project for fun) the idea is simple, the user add links to the main page for items he want ( ex: https://www.amazon.fr/Bracelet-ethnique-multicolore-pierres-aventurine/dp/B088FNK7WS?pd_rd_w=VcswS&pf_rd_p=93b57529-44d6-414c-8e38-22f57431b7bd&pf_rd_r=F71JXZXPJQFHJR7E6ZCB&pd_rd_r=5c6a3226-b724-44f0-9c7c-1f7d75b21c00&pd_rd_wg=AJYnZ ), links are stored to an array, ect... for a better visual, i want to prefill the name of the item and display a picture of this item based on the open graph data of the link (if available), for this usage, i found this plugin: https://metascraper.js.org#/?id=usage (work fine) to scrap the metadata of the page i target.
My problem is the following:
when i do a simple this.$axios.$get(link)
i have a cors issue (No** 'Access-Control-Allow-Origin' header is present on the requested resource**.) After some research, i found this error is due to Server Side Rendering and need to be solved with the usage of a proxy.
But the use of @nuxt/proxy need to define one proxy per website (ex: '/amazon/': { target: 'https://amazon.com/', pathRewrite: { '^/amazon/': '' } }
)
Or, i need to scrap data from any link my user put in her wishlist. Can i still use @nuxt/proxy or i need a more complex solution ?
...ANSWER
Answered 2020-Oct-26 at 09:05This error is actually a browser security feature, and it's triggered when you try to access a resource from a different origin, read more here
To work around it, simply fire the scrapping request from the server-side, this way you can make your server act as a proxy. And since you are using nuxt you can easily achieve this through server-middleware, thus you can create a custom API e.g: /api/meta-scraper?target=http://www.amazon.com... and from there you can fetch the needed metadata. See the below example code.
nuxt.config.js
QUESTION
I'm using Html Agility Pack to get meta tags from URLs. I was using HtmlWeb
's Load
, but I found it to be taking too long and thought that I could probably speed up performance using an async method instead. However, when I tried to use LoadFromWebAsync
I get a NullReferenceException.
Using Load
ANSWER
Answered 2020-Oct-05 at 08:31The issue was that I was attempting to show the data before it was loaded. This was because I was using async but not providing something to show while it was awaiting a result. It can be fixed by doing:
QUESTION
When an user submit a post with an URL. I want to get the Open Graph meta of the URL without a back-end server.
I've found libraries that can extract Open Graph meta such as opengraph-io and metascraper, but they all require a Node.js server to do the job.
Is it possible to achieve this on client side only?
...ANSWER
Answered 2020-Jul-07 at 08:17I have found a solution. Posting this answer to help anyone who is searching for a similar solution.
https://www.opengraph.io/ provides up to 100 requests a month free. You need to signup to get the API key to place into the app_id. In just few lines of code, I get the meta data in a response object:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install metascraper
Have a high accuracy for online articles by default.
Make it simple to add new rules or override existing ones.
Don't restrict rules to CSS selectors or text accessors.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page