您正在使用ScrapIt库中的以下方法签名
declare function scrapeIt<T>(url: string | object, opts:scrapeIt.ScrapeOptions): Promise<T>;
这意味着该方法的第二个参数
scraptIt()
应为类型
ScrapeOptions
. 如果您遵守接口的定义
刮取选项
您可以仔细地看到,它接受以下格式作为输入
export interface ScrapeOptions {
[key: string]: string | ScrapeOptionList | ScrapeOptionElement;
}
这个
ScrapeOptionList
接口定义为
export interface ScrapeOptionList {
listItem: string;
data: ScrapeOptions;
}
在代码中传递第二个参数,如下所示
scraptIt(firebaseFunctions.config().sports.url + element.data().url, {
sports: {
listItem: '.LSport',
data: ['b'] // here is the issue
}
})
的值
data
应为类型
刮取选项
根据定义。因此,您需要将其更改为简单字符串或
刮选列表
或类型
ScrapeOptionElement
.
您可以尝试将其更改为
data: 'b'
根据您的需要
或设置
数据
属性值作为类型
刮选列表
或
ScrapeOptionElement
.
要使用的示例格式如下所示--(不确定为什么要使用
data:['b']
) . 在我看来应该是
data : { "somekey" : 'b'}
pages: {
listItem: "li.page"
, name: "pages"
, data: {
title: "a"
, url: {
selector: "a"
, attr: "href"
}
}
}