AndrejGajdos / link-preview-generator

Get preview data (a title, description, image, domain name) from a url. Library uses puppeteer headless browser to scrape the web site.
MIT License
263 stars 65 forks source link

Get a favicon (feature request) #25

Closed koukikitamura closed 2 years ago

koukikitamura commented 2 years ago

I want to get a favicon as preview data. Can you merge a PR if I implement the following?

// index.js
const getFavicon = async (page, uri) => { // New
  ...
  return favicon
}

module.exports = async (
  uri,
  puppeteerArgs = [],
  puppeteerAgent = "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)",
  executablePath
) => {
  puppeteer.use(pluginStealth());
  ...
  const obj = {};
  obj.title = await getTitle(page);
  obj.description = await getDescription(page);
  obj.domain = await getDomainName(page, uri);
  obj.img = await getImg(page, uri);
  ojb.favicon = await getFavicon(page, uri) // New

  await browser.close();
  return obj;
};
AndrejGajdos commented 2 years ago

@koukikitamura I will merge it for sure :)

koukikitamura commented 2 years ago

Thank you! I'll implement the above.

koukikitamura commented 2 years ago

@AndrejGajdos I implemented https://github.com/AndrejGajdos/link-preview-generator/pull/26. Please check the PR when you have time.

AndrejGajdos commented 2 years ago

@koukikitamura I just merged your PR. Thanks again for your contribution. I think we can close this.