Skip to content

Commit

Permalink
Merge pull request #59 from fmacpro/development
Browse files Browse the repository at this point in the history
get site icon url functionality
  • Loading branch information
fmacpro authored Aug 31, 2021
2 parents 697034c + 3ea4796 commit b28a125
Show file tree
Hide file tree
Showing 4 changed files with 2,670 additions and 2,863 deletions.
9 changes: 9 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ const articleParser = async function (options, socket) {
article.mobile = await page.screenshot({ encoding: 'base64', type: 'jpeg', quality: 60 })
}

// Evaluate site icon url
if (options.enabled.includes('siteicon')) {
socket.emit('parse:status', 'Evaluating site icon')
article.siteicon = await page.evaluate(() => {
var j = window.$
return j('link[rel~="icon"]').prop('href')
})
}

// Evaluate meta
socket.emit('parse:status', 'Evaluating Meta Data')

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "horseman-article-parser",
"version": "0.8.53",
"version": "0.8.54",
"description": "Web Page Inspection Tool. Sentiment Analysis, Keyword Extraction, Named Entity Recognition & Spell Check",
"main": "index.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const testPlugin = function (Doc, world) {

const options = {
url: 'https://www.theguardian.com/commentisfree/2021/jan/07/what-happened-in-washington-dc-is-happening-around-the-world',
enabled: ['lighthouse', 'screenshot', 'links', 'sentiment', 'entities', 'spelling', 'keywords'],
enabled: ['lighthouse', 'screenshot', 'links', 'sentiment', 'entities', 'spelling', 'keywords', 'siteicon'],
nlp: {
plugins: [testPlugin]
}
Expand All @@ -24,6 +24,7 @@ parser.parseArticle(options)
excerpt: article.excerpt,
metadescription: article.meta.description.text,
url: article.url,
siteicon: article.siteicon,
sentiment: { score: article.sentiment.score, comparative: article.sentiment.comparative },
keyphrases: article.processed.keyphrases,
keywords: article.processed.keywords,
Expand Down
Loading

0 comments on commit b28a125

Please sign in to comment.