mirror of
https://github.com/misskey-dev/summaly.git
synced 2025-05-19 04:27:27 +09:00
Merge pull request #20 from armchair-philosophy/update_cheerio-httpcli
follow cheerio-httpcli update
This commit is contained in:
commit
ce2481d6ce
@ -8,9 +8,9 @@ const escapeRegExp = require('escape-regexp');
|
|||||||
const Entities = require('html-entities').AllHtmlEntities;
|
const Entities = require('html-entities').AllHtmlEntities;
|
||||||
const entities = new Entities();
|
const entities = new Entities();
|
||||||
|
|
||||||
const client = require('cheerio-httpcli');
|
import * as client from 'cheerio-httpcli';
|
||||||
client.referer = false;
|
client.set('referer', false);
|
||||||
client.timeout = 10000;
|
client.set('timeout', 10000);
|
||||||
|
|
||||||
import ISummary from './isummary';
|
import ISummary from './isummary';
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ export default async (url: URL.Url): Promise<ISummary> => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const $: any = res.$;
|
const $: client.CheerioStaticEx = res.$;
|
||||||
|
|
||||||
let title =
|
let title =
|
||||||
$('meta[property="og:title"]').attr('content') ||
|
$('meta[property="og:title"]').attr('content') ||
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import * as URL from 'url';
|
import * as URL from 'url';
|
||||||
|
|
||||||
const client = require('cheerio-httpcli');
|
import * as client from 'cheerio-httpcli';
|
||||||
client.referer = false;
|
client.set('referer', false);
|
||||||
client.timeout = 10000;
|
client.set('timeout', 10000);
|
||||||
|
|
||||||
export function test (url: URL.Url) {
|
export function test (url: URL.Url) {
|
||||||
return url.hostname === 'www.amazon.com' ||
|
return url.hostname === 'www.amazon.com' ||
|
||||||
@ -23,7 +23,7 @@ export function test (url: URL.Url) {
|
|||||||
|
|
||||||
export async function summary (url: URL.Url) {
|
export async function summary (url: URL.Url) {
|
||||||
const res = await client.fetch(url.href);
|
const res = await client.fetch(url.href);
|
||||||
const $: any = res.$;
|
const $: client.CheerioStaticEx = res.$;
|
||||||
|
|
||||||
const title: string = $('#title').text();
|
const title: string = $('#title').text();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user