f111fei / article_spider

微信公众号爬虫
317 stars 72 forks source link

error TS2339: Property 'attribs' does not exist on type 'Element'. #11

Open gao-zhi-ustc opened 3 years ago

gao-zhi-ustc commented 3 years ago

article_spider % tsc src/wechat/parser.ts:207:29 - error TS2339: Property 'attribs' does not exist on type 'Element'. Property 'attribs' does not exist on type 'TextElement'.

207 const src = img.attribs['data-src'] || img.attribs['data-backsrc'] || img.attribs['src'];


src/wechat/parser.ts:207:56 - error TS2339: Property 'attribs' does not exist on type 'Element'.
  Property 'attribs' does not exist on type 'TextElement'.

207             const src = img.attribs['data-src'] || img.attribs['data-backsrc'] || img.attribs['src'];

src/wechat/parser.ts:207:87 - error TS2339: Property 'attribs' does not exist on type 'Element'. Property 'attribs' does not exist on type 'TextElement'.

207 const src = img.attribs['data-src'] || img.attribs['data-backsrc'] || img.attribs['src'];


src/wechat/parser.ts:208:30 - error TS2339: Property 'attribs' does not exist on type 'Element'.
  Property 'attribs' does not exist on type 'TextElement'.

208             const type = img.attribs['data-type'] || 'jpg';

src/wechat/parser.ts:213:38 - error TS2339: Property 'attribs' does not exist on type 'Element'. Property 'attribs' does not exist on type 'TextElement'.

213 imagesMeta.push({ ...img.attribs });


src/wechat/parser.ts:229:28 - error TS2339: Property 'tagName' does not exist on type 'TextElement | TagElement | CommentElement'.
  Property 'tagName' does not exist on type 'TextElement'.

229                 img.parent.tagName === 'p' && (contentElement.find('p')[0] === img.parent)) {

typings/crawler.d.ts:9:16 - error TS2304: Cannot find name 'CheerioAPI'.

9 $: CheerioAPI;



Found 7 errors.
linzhk commented 3 years ago

我也遇到了,正好7个错误