我试图让用户看到反应原生的网页预览,例如在Facebook和其他应用上看到的链接预览。我做了一些研究。
我见过一些为节点提供函数的库,但它不适用于react-native(因为原来的cheerio.js不能直接与react-native一起工作)
https://github.com/cheeriojs/cheerio
我也检查了oEmbed库,但它似乎也没有用。
我想知道什么是获取网页预览的好方法
答案 0 :(得分:2)
结束编写一个完成工作的小型库。希望它对某些人有用
https://github.com/changey/react-native-page-previewer
用法
import preview from 'react-native-page-previewer';
preview("http://www.google.com", function(err, data) {
if(!err) {
console.log(data);
}
});
样本返回
{ url: 'https://www.google.com',
loadFailed: false,
title: 'Google',
description: 'Search the world\'s information, including webpages, images, videos and more. Google has many special features to help you find exactly what you\'re looking for.',
contentType: 'text/html',
mediaType: 'website',
images: [ 'https://www.google.com/images/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png' ],
videos: undefined,
audios: undefined }