huiwang / hexo-recommended-posts Goto Github PK
View Code? Open in Web Editor NEWKeyword based cross blog posts recommendation / Hexo跨博客文章互推插件,共享空间,提升流量
License: GNU Affero General Public License v3.0
Keyword based cross blog posts recommendation / Hexo跨博客文章互推插件,共享空间,提升流量
License: GNU Affero General Public License v3.0
如题
@huiwang 先感谢您的付出。
我用这个插件在本地测试的时候发现了一些问题:
Unable to download recommendatoin from server { RequestError: Error: read ECONNRESET
......
但不是每次都会出现,有时可以成功生成recommended_posts.json。
在已生成recommend_posts.json的前提下,不是所有文章下面都有推荐,而且同一文章可能这次看有推荐,下一次就没有推荐了。
推荐外链中有死链,遇到过一次,不过没有记录下来。还有人放了绑架挖矿的js在自己博客上。
边栏上的推荐如何关闭?
uri:
Url {
protocol: 'https:',
slashes: true,
auth: null,
host: 'api.truelaurel.com',
port: 443,
hostname: 'api.truelaurel.com',
hash: null,
search: null,
query: null,
pathname: '/recommendation',
path: '/recommendation',
href: 'https://api.truelaurel.com/recommendation' },
method: 'POST',
_maxListeners: undefined,
_eventsCount: 3,
_events:
[Object: null prototype] {
error: [Function: bound ],
complete: [Function: bound ],
pipe: [Function],
data: [Function],
end: [Function] },
_defaultAgent: [Circular],
servername: 'api.truelaurel.com',
singleUse: true } } ] },
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
maxCachedSessions: 100,
_sessionCache:
{ map:
{ 'api.truelaurel.com:443::::::::::::::::':
<Buffer 30 82 05 b0 02 01 01 02 02 03 03 04 02 c0 2f 04 20ff 71 8c 7f 61 03 28 2c 5c 66 98 27 ad 5d 74 f1 ea 23 19 30 1c f6 0b f6 da fe ba 01 ec 38 b1 97 04 ... 1410 more bytes> },
list: [ 'api.truelaurel.com:443::::::::::::::::' ] } },
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/recommendation',
_ended: true,
res: [Circular],
aborted: false,
timeoutCb: null,
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(isCorked)]: false,
[Symbol(outHeadersKey)]:
[Object: null prototype] {
host: [ 'host', 'api.truelaurel.com' ],
accept: [ 'accept', 'application/json' ],
'content-type': [ 'content-type', 'application/json' ],
'content-length': [ 'content-length', 906727 ] } },
ntick: true,
response: [Circular],
originalHost: 'api.truelaurel.com',
originalHostHeaderName: 'host',
responseContent: [Circular],
_destdata: true,
_ended: true,
_callbackCalled: true },
toJSON: [Function: responseToJSON],
caseless:
Caseless {
dict:
{ 'content-type': 'application/json',
'content-length': '194',
connection: 'close',
date: 'Mon, 11 Mar 2019 12:50:24 GMT',
'x-amzn-requestid': '3c331134-43fc-11e9-ad87-7f02ef1ae103',
'x-amz-apigw-id': 'WYLuYGUHoAMFn2A=',
'x-amzn-trace-id': 'Root=1-5c86598d-4f3ee0a00b1c03d8cf06c178;Sampled=0',
'x-cache': 'Error from cloudfront',
via:
'1.1 86eb67c9cdffbb1cad0c7a18a9b0f5a5.cloudfront.net (CloudFront)',
'x-amz-cf-id': '0Xa6FxvJ6cOqtPwyeDE1v2Ya_880OThMeT9r_wZaELXN0Q_T1N8wDg==' } },
body:
'Item size has exceeded the maximum allowed size (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ValidationException; Request ID: 2RHRNOLJR7UV4QQA5A690MM0TNVV4KQNSO5AEMVJF66Q9ASUAAJG)' } }
超出允许最大值这指的是什么呢?是单个tag下的文章个数太多,还是总文章数大多?
对于使用 maupassant 的小伙伴, 我在 maupassant 主题中添加了对这个插件的支持.
这里是相关教程.
看效果,可定制程度不高啊
只能定制推荐的头部标题?
我是想获取文章的封面,然后自己写样式
会不会api接口形式会好点呢?
还有能说说原理?
怎样获取每个站点的文章信息?
爬虫?
打算做个api形式的
现在发现当某个 Tag 只有一篇文章时, 推荐结果就会返回一个空的列表.
觉得如果在推荐结果为空的情况下, 返回一个默认的推荐列表可能会更好一些.
没有事先检查是否死链的吗?频率倒是不必太高。
也没有报错,按照介绍安装和运行后 推荐文章依然没有展示出来。
_data/recommended_posts.json 文件能够正常下载。
运行hexo recommend
Unhandled rejection TypeError: Cannot read property 'count' of undefined
比如现在我有 58 篇文章,打开每篇文章然后再手动加入太麻烦了,需要在~/blog/themes/next/layout/_macro/post.swig
加入什么代码?:smile:
😄 已经迫不及待用上了,但是发现一个奇怪的现象。
_config.yml
里的internalLinks
和externalLinks
的配置不生效,好像都是内链最多 3 个,外链最多 2 个,总数最多 5 个,无论两个的数值分别是多少,总和是多少。
README自定义原文:
recommended_posts:
server: https://api.truelaurel.com #后端推荐服务器地址
timeoutInMillis: 10000 #服务时长,超过此时长,则使用离线推荐模式
internalLinks: 3 #内部文章数量
externalLinks: 1 #外部文章数量
fixedNumber: false
autoDisplay: true, #自动在文章底部显示推荐文章
excludePattern: [],
titleHtml: <h1>推荐文章<span style="font-size:0.45em; color:gray">(由<a href="https://github.com/huiwang/hexo-recommended-posts">hexo文章推荐插件</a>驱动)</span></h1> #自定义标题
倒数第二、三行多个逗号,如果hexo recommend则会出现错误。
name: 'RequestError',
message: 'Error: read ETIMEDOUT',
cause: { Error: read ETIMEDOUT
at TLSWrap.onread (net.js:659:25) errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'read' },
error: { Error: read ETIMEDOUT
at TLSWrap.onread (net.js:659:25) errno: 'ETIMEDOUT', code: 'ETIMEDOUT', syscall: 'read' },
options:
{ method: 'POST',
baseUrl: 'https://api.truelaurel.com',
uri: 'recommendation',
body: { internal: 3, external: 1, site: [Object] },
json: true,
callback: [Function: RP$callback],
transform: undefined,
simple: true,
resolveWithFullResponse: false,
transform2xxOnly: false },
response: undefined }
做为一个有多年SEO经验的博主担心你的开发会被利用。多年SEO经验让我感觉这个功能会被利用,有些SEO人员会不择手段利用所有资源。只要利用好你的匹配规则。而且更是开源的
我在博客中使用了这个插件,发现一个问题,下面的页面是无法打开的:https://blog.yuanpei.me/posts/3444626340/
而下面这个页面则是正常的:
https://blog.yuanpei.me/posts/3846545990/
所以,不是很明白,为什么会这样子,麻烦作者解答下我的困惑
后端服务器是不支持了吗?
我在根目录下运行hexo recommend
之后,
在source\_data
生成了recommended_posts.json
,
但是,每篇文章下面依旧没有你们那样的推荐文章,什么变化也没有。
不会要自己读取recommended_posts.json
的数据再显示吧?
如题,部分站长可能没有正确配置,提交了example.com
还有站长切换链接等情况
是不是没人用了?没数据?
INFO Unable to download recommendatoin from server { RequestError: Error: certificate has expired
执行hexo recommend
后报错如下:
INFO Start fetching recommendation with config {"server":"https://api.trueaurel.com","timeoutInMillis":10000,"internallinks":3,"externalLinks":1,"autoDisplay":true,"titleHtml":"<h1>推荐文章.........} // 此处省略,为默认设置
INFO Unable to download recommendatoin from server { StatusCodeError: 403 - {"message":"Missing Authentication Token"}
at new StatusCodeError (C:\Users\abel1\MyBlog\node_modules\request-promise-core\lib\errors.js:32:15)
at Request.plumbing.callback (C:\Users\abel1\MyBlog\node_modules\request-promise-core\lib\plumbing.js:104:33)
at Request.RP$callback [as _callback] (C:\Users\abel1\MyBlog\node_modules\request-promise-core\lib\plumbing.js:46:31)
at Request.self.callback (C:\Users\abel1\MyBlog\node_modules\request\request.js:186:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (C:\Users\abel1\MyBlog\node_modules\request\request.js:1163:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (C:\Users\abel1\MyBlog\node_modules\request\request.js:1085:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1055:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
name: 'StatusCodeError',
statusCode: 403,
message: '403 - {"message":"Missing Authentication Token"}',
error: { message: 'Missing Authentication Token' },
options:
{ method: 'POST',
baseUrl: 'https://api.truelaurel.com',
uri: 'posts',
body:
{ permalink: 'https://abelsu7.top/2018/02/28/ethereum-virtual-machine/',
title: '以太坊虚拟机(EVM)底层原理及性能缺陷',
tags: [Array] },
json: true,
timeout: 10000,
callback: [Function: RP$callback],
transform: undefined,
simple: true,
resolveWithFullResponse: false,
transform2xxOnly: false },
response:
IncomingMessage {
_readableState:
ReadableState {
objectMode: false,
highWaterMark: 16384,
buffer: [Object],
length: 0,
pipes: null,
pipesCount: 0,
flowing: true,
ended: true,
endEmitted: true,
reading: false,
sync: true,
needReadable: false,
emittedReadable: false,
readableListening: false,
resumeScheduled: false,
destroyed: false,
defaultEncoding: 'utf8',
awaitDrain: 0,
readingMore: false,
decoder: null,
encoding: null },
readable: false,
domain: null,
_events:
{ end: [Array],
close: [Array],
data: [Function],
error: [Function] },
_eventsCount: 4,
_maxListeners: undefined,
socket:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.truelaurel.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
_bytesDispatched: 324,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Object],
read: [Function],
_consuming: true,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 5150,
_destroyed: false,
[Symbol(asyncId)]: 3233,
[Symbol(bytesRead)]: 496,
[Symbol(asyncId)]: 3372,
[Symbol(triggerAsyncId)]: 3350 },
connection:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.truelaurel.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
_bytesDispatched: 324,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Object],
read: [Function],
_consuming: true,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 5150,
_destroyed: false,
[Symbol(asyncId)]: 3233,
[Symbol(bytesRead)]: 496,
[Symbol(asyncId)]: 3372,
[Symbol(triggerAsyncId)]: 3350 },
httpVersionMajor: 1,
httpVersionMinor: 1,
httpVersion: '1.1',
complete: true,
headers:
{ 'content-type': 'application/json',
'content-length': '43',
connection: 'close',
date: 'Sun, 01 Apr 2018 07:00:48 GMT',
'x-amzn-requestid': '6804148c-357a-11e8-84f5-6be754b5776e',
'x-amzn-errortype': 'MissingAuthenticationTokenException',
'x-amz-apigw-id': 'EpmBCGK-IAMFRww=',
'x-cache': 'Error from cloudfront',
via: '1.1 95a0324d8eebee0dcc28a46e19d11546.cloudfront.net (CloudFront)',
'x-amz-cf-id': 'FdHrLnNm4gYSDo_IvVSHZDEN32x6VOaGzsQuW-Lo-iqyFV7Cg1DcYA==' },
rawHeaders:
[ 'Content-Type',
'application/json',
'Content-Length',
'43',
'Connection',
'close',
'Date',
'Sun, 01 Apr 2018 07:00:48 GMT',
'x-amzn-RequestId',
'6804148c-357a-11e8-84f5-6be754b5776e',
'x-amzn-ErrorType',
'MissingAuthenticationTokenException',
'x-amz-apigw-id',
'EpmBCGK-IAMFRww=',
'X-Cache',
'Error from cloudfront',
'Via',
'1.1 95a0324d8eebee0dcc28a46e19d11546.cloudfront.net (CloudFront)',
'X-Amz-Cf-Id',
'FdHrLnNm4gYSDo_IvVSHZDEN32x6VOaGzsQuW-Lo-iqyFV7Cg1DcYA==' ],
trailers: {},
rawTrailers: [],
upgrade: false,
url: '',
method: null,
statusCode: 403,
statusMessage: 'Forbidden',
client:
TLSSocket {
_tlsOptions: [Object],
_secureEstablished: true,
_securePending: false,
_newSessionPending: false,
_controlReleased: true,
_SNICallback: null,
servername: null,
npnProtocol: false,
alpnProtocol: false,
authorized: true,
authorizationError: null,
encrypted: true,
_events: [Object],
_eventsCount: 10,
connecting: false,
_hadError: false,
_handle: null,
_parent: null,
_host: 'api.truelaurel.com',
_readableState: [Object],
readable: false,
domain: null,
_maxListeners: undefined,
_writableState: [Object],
writable: false,
allowHalfOpen: false,
_bytesDispatched: 324,
_sockname: null,
_pendingData: null,
_pendingEncoding: '',
server: undefined,
_server: null,
ssl: null,
_requestCert: true,
_rejectUnauthorized: true,
parser: null,
_httpMessage: [Object],
read: [Function],
_consuming: true,
_idleTimeout: -1,
_idleNext: null,
_idlePrev: null,
_idleStart: 5150,
_destroyed: false,
[Symbol(asyncId)]: 3233,
[Symbol(bytesRead)]: 496,
[Symbol(asyncId)]: 3372,
[Symbol(triggerAsyncId)]: 3350 },
_consuming: true,
_dumped: false,
req:
ClientRequest {
domain: null,
_events: [Object],
_eventsCount: 6,
_maxListeners: undefined,
output: [],
outputEncodings: [],
outputCallbacks: [],
outputSize: 0,
writable: true,
_last: true,
upgrading: false,
chunkedEncoding: false,
shouldKeepAlive: false,
useChunkedEncodingByDefault: true,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: null,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
socket: [Object],
connection: [Object],
_header: 'POST /posts HTTP/1.1\r\nhost: api.truelaurel.com\r\naccept: application/json\r\ncontent-type: application/json\r\ncontent-length: 176\r\nConnection: close\r\n\r\n',
_onPendingData: [Function: noopPendingOutput],
agent: [Object],
socketPath: undefined,
timeout: undefined,
method: 'POST',
path: '/posts',
_ended: true,
res: [Circular],
aborted: undefined,
timeoutCb: [Function: emitTimeout],
upgradeOrConnect: false,
parser: null,
maxHeadersCount: null,
[Symbol(outHeadersKey)]: [Object] },
request:
Request {
domain: null,
_events: [Object],
_eventsCount: 5,
_maxListeners: undefined,
method: 'POST',
uri: [Object],
body: '{"permalink":"https://abelsu7.top/2018/02/28/ethereum-virtual-machine/","title":"以太坊虚拟机(EVM)底层原理及性能缺陷","tags":["区块链","以太坊","EVM"]}',
timeout: 10000,
readable: true,
writable: true,
explicitMethod: true,
_qs: [Object],
_auth: [Object],
_oauth: [Object],
_multipart: [Object],
_redirect: [Object],
_tunnel: [Object],
_rp_resolve: [Function],
_rp_reject: [Function],
_rp_promise: [Object],
_rp_callbackOrig: undefined,
callback: [Function],
_rp_options: [Object],
headers: [Object],
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
pool: {},
dests: [],
__isRequestRequest: true,
_callback: [Function: RP$callback],
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_disableCookies: true,
_jar: undefined,
port: 443,
host: 'api.truelaurel.com',
path: '/posts',
_json: true,
httpModule: [Object],
agentClass: [Object],
agent: [Object],
_started: true,
href: 'https://api.truelaurel.com/posts',
req: [Object],
ntick: true,
timeoutTimer: null,
response: [Circular],
originalHost: 'api.truelaurel.com',
originalHostHeaderName: 'host',
responseContent: [Circular],
_destdata: true,
_ended: true,
_callbackCalled: true },
toJSON: [Function: responseToJSON],
caseless: Caseless { dict: [Object] },
read: [Function],
body: { message: 'Missing Authentication Token' } } }
能不能有个检测机制,把推荐的外链中的无效链接去除?我的博客现在与这个域名( www.davidfnck.com )关联了 26 个链接(查看 recommended_posts.json 文件得知 ),现在博客也就才 64 篇文章,意味着有将近一半的文章下方都有推这个域名(设置是 4 个内链,1 个外链),而打开后这个域名的外链后,都报 404,然后手动访问这个域名,发现该博客的推荐文章没有外链(而我的博客有 26 个),且有默认开启的挖矿程序,这令人感到很恶心啊!
、
如图是我的本地预览界面,这三个一模一样的文章链接地址分别是:
https://qinyuanpei.github.io/posts/2275646954/
https://blog.yuanpei.me/posts/2275646954/
http://localhost:4000/posts/2275646954/
前两个,应该是推荐文章的github地址和自己的域名地址,第三个不清楚咋回事= = 但是三篇文章都是一样的
附上我的config
recommended_posts:
server: https://api.truelaurel.com #后端推荐服务器地址
timeoutInMillis: 10000 #服务时长,超过此时长,则使用离线推荐模式
internalLinks: 2 #内部文章数量
externalLinks: 3 #外部文章数量
fixedNumber: false
autoDisplay: true #自动在文章底部显示推荐文章
excludePattern: []
titleHtml:
▶ 推荐文章(由hexo文章推荐插件驱动)
#自定义标题如题
问题是这样的,如果一个网站,只使用内链,那么其他的博客使用外链的时候,就不应该推荐这个人的文章。
什么是推荐权重?为了增加推荐的公平性,我们对每一个文章都测量出它的权重。它的权重,主要取决于它给别人带来的流量。一个文章的权重越高,它被别人当成外链推荐的可能性就越大。
如何测量?当有人在推荐列表点击一个文章的时候,就创建一个新的引流记录。
大家怎么看?
Request {
_events: [Object],
_eventsCount: 5,
_maxListeners: undefined,
method: 'POST',
uri: [Url],
body: '{"permalink":"http://www.meng.uno/articles/7d26fe8/","title":"CryptoMinisat","tags":["CryptoMinisat","SAT","solver"]}',
timeout: 10000,
readable: true,
writable: true,
explicitMethod: true,
_qs: [Querystring],
_auth: [Auth],
_oauth: [OAuth],
_multipart: [Multipart],
_redirect: [Redirect],
_tunnel: [Tunnel],
_rp_resolve: [Function],
_rp_reject: [Function],
_rp_promise: [Promise],
_rp_callbackOrig: undefined,
callback: [Function],
_rp_options: [Object],
headers: [Object],
setHeader: [Function],
hasHeader: [Function],
getHeader: [Function],
removeHeader: [Function],
localAddress: undefined,
pool: {},
dests: [],
__isRequestRequest: true,
_callback: [Function: RP$callback],
proxy: null,
tunnel: true,
setHost: true,
originalCookieHeader: undefined,
_disableCookies: true,
_jar: undefined,
port: 443,
host: 'api.truelaurel.com',
path: '/posts',
_json: true,
httpModule: [Object],
agentClass: [Function],
agent: [Agent],
_started: true,
href: 'https://api.truelaurel.com/posts',
req: [ClientRequest],
ntick: true,
timeoutTimer: null,
response: [Circular],
originalHost: 'api.truelaurel.com',
originalHostHeaderName: 'host',
responseContent: [Circular],
_destdata: true,
_ended: true,
_callbackCalled: true },
toJSON: [Function: responseToJSON],
caseless: Caseless { dict: [Object] },
read: [Function],
body: { message: 'Missing Authentication Token' } } }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.