关于安装的信息:
我已经成功地在我自己的服务器Ubuntu16上安装了https://github.com/prerender/prerender。
这是我的.htaccess,当检测到爬虫时,它会将url重写到预存器。示例:http://www.example.nl/63/Merry变成http://example.nl:3000/http://www.example.nl/63/Merry
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|redditbot|slackbot|msnbot|googlebot|duckduckbot|bingbot|rogerbot|linkedinbot|embedly|flipboard|tumblr|bitlybot|SkypeUriPreview|nuzzel|Discordbot|quora\ link\ preview|showyoubot|outbrain|pinterest [NC,OR]
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=$
RewriteRule ^(.*)$ http://example.nl:3000/http://www.example.nl/$1? [R=301,L]
#RewriteRule ^(.*)$ http://art.example.net/$1? [R=301,L]
RewriteRule ^(.*)/(.*)$ /#$1/$2 [NC,L]问题:
当使用预制板时,元数据不会在Skype、Reddit、Twitter上加载。将url重写到旧的PHP网站:http://art.example.net (目前在htaccess中有注释)确实有效。因为PHP和prerenderer上的所有元标签都是相同的,所以最有可能的原因是预录制器。
使用Prerender的Twitter错误示例(https://cards-dev.twitter.com/validator使用url:http://example.nl/63/Merry):
ERROR: Failed to fetch page due to: HttpConnectionTimeout
WARN: this card is redirected to http://example.nl:3000/http://www.example.nl/63/Merry重定向到art.example.net时的Twitter (也使用主URL:http://example.nl/63/Merry)
INFO: Page fetched successfully
INFO: 19 metatags were found
INFO: twitter:card = summary_large_image tag found
INFO: Card loaded successfully
WARN: this card is redirected to http://art.example.net/63/Merry使用PHP版本可以工作,所有元数据都将被加载。
在未来,我想完全删除PHP网站,所以我真的很想让它与Prerender一起工作。Prerender确实在不和谐和邮差中工作(修改了用户代理报头)。我只是不知道为什么对其他探员不管用。
发布于 2017-05-15 00:45:31
重写规则应该是代理,而不是重定向。重定向到您的预发布服务器将导致各种问题,包括告诉Google从搜索结果中直接将用户发送到您的预分发程序服务器(这真的很糟糕!)
重写规则部分应是:
RewriteRule ^(.*)$ http://example.nl:3000/http://www.example.nl/$1? [P,L]发布于 2017-05-13 18:14:47
解决办法:
Twitter和其他爬虫无法处理网址中的点和“:”。因此不允许使用简单的IP地址和端口号。
要解决这个问题,您可以创建一个子域,该子域重定向到Node.js应用程序。
我的子域Apache虚拟主机:
<VirtualHost *:80>
ServerAdmin info@example.net
ServerName prerender.example.net
ServerAlias prerender.example.net
ProxyPass / http://localhost:3000/ connectiontimeout=5 timeout=30
</VirtualHost>再加上prerender.io自己的答案,我设法让它发挥作用。
虽然代理和重定向对社交媒体爬虫并不重要,因为URL已经粘贴在那里了。使用代理标记是很好的做法。
https://stackoverflow.com/questions/43954012
复制相似问题