fix: improvements to scraping (#2702)

- fixes #2690
This commit is contained in:
Wyatt Johnson
2019-11-12 17:25:41 +00:00
committed by GitHub
parent b83d737530
commit 2ef07429c2
8 changed files with 313 additions and 306 deletions
+5 -14
View File
@@ -1,10 +1,4 @@
declare module "metascraper" {
export interface Scraper {
(options: { url: string; html: string }): Promise<
Record<string, string | undefined>
>;
}
export type Ruler = (options: {
htmlDom: CheerioSelector;
url: string;
@@ -16,8 +10,6 @@ declare module "metascraper" {
) => string | undefined;
export type Rules = Record<string, Array<Ruler>>;
export function load(rules: Rules[]): Scraper;
}
declare module "metascraper-author" {
@@ -25,11 +17,6 @@ declare module "metascraper-author" {
export default function def(): Rules;
}
declare module "metascraper-date" {
import { Rules } from "metascraper";
export default function def(): Rules;
}
declare module "metascraper-description" {
import { Rules } from "metascraper";
export default function def(): Rules;
@@ -46,5 +33,9 @@ declare module "metascraper-title" {
}
declare module "@metascraper/helpers" {
export const $jsonld: any;
import { Rule } from "metascraper";
export const $jsonld: (key: string) => Rule;
export const jsonld: (url: string, htmlDom: CheerioSelector) => Rule;
export const toRule: (fn: any, opts?: any) => (rule: Rule) => any;
export const date: Rule;
}