Skip to content

Commit b28a125

Browse files
authored
Merge pull request #59 from fmacpro/development
get site icon url functionality
2 parents 697034c + 3ea4796 commit b28a125

File tree

4 files changed

+2670
-2863
lines changed

4 files changed

+2670
-2863
lines changed

index.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ const articleParser = async function (options, socket) {
170170
article.mobile = await page.screenshot({ encoding: 'base64', type: 'jpeg', quality: 60 })
171171
}
172172

173+
// Evaluate site icon url
174+
if (options.enabled.includes('siteicon')) {
175+
socket.emit('parse:status', 'Evaluating site icon')
176+
article.siteicon = await page.evaluate(() => {
177+
var j = window.$
178+
return j('link[rel~="icon"]').prop('href')
179+
})
180+
}
181+
173182
// Evaluate meta
174183
socket.emit('parse:status', 'Evaluating Meta Data')
175184

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "horseman-article-parser",
3-
"version": "0.8.53",
3+
"version": "0.8.54",
44
"description": "Web Page Inspection Tool. Sentiment Analysis, Keyword Extraction, Named Entity Recognition & Spell Check",
55
"main": "index.js",
66
"scripts": {

test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const testPlugin = function (Doc, world) {
1111

1212
const options = {
1313
url: 'https://www.theguardian.com/commentisfree/2021/jan/07/what-happened-in-washington-dc-is-happening-around-the-world',
14-
enabled: ['lighthouse', 'screenshot', 'links', 'sentiment', 'entities', 'spelling', 'keywords'],
14+
enabled: ['lighthouse', 'screenshot', 'links', 'sentiment', 'entities', 'spelling', 'keywords', 'siteicon'],
1515
nlp: {
1616
plugins: [testPlugin]
1717
}
@@ -24,6 +24,7 @@ parser.parseArticle(options)
2424
excerpt: article.excerpt,
2525
metadescription: article.meta.description.text,
2626
url: article.url,
27+
siteicon: article.siteicon,
2728
sentiment: { score: article.sentiment.score, comparative: article.sentiment.comparative },
2829
keyphrases: article.processed.keyphrases,
2930
keywords: article.processed.keywords,

0 commit comments

Comments
 (0)