跳到主要内容
CNode
查看回复

回复 (5)

Y
yakczh#58 年前

@quanpf2481 table tr:first-child

Q
quanpf2481#48 年前
引用 yakczh

@yakczh 如果我只想爬某一条特定的数据,应该怎么处理呢?比如说我想要第一条数据

Y
yakczh#28 年前
const  cheerio = require('cheerio');
const  fetch = require("node-fetch");

var url = 'http://www.maigoo.com/news/463071.html';
 
async function get(url){
var data= await fetch(url);
return data;
}

get(url).then(res => res.text())
	.then(body => {  
	$ = cheerio.load(body.toString());
	$("table tr").each(function(i, e) {
        console.log($(e).text());
    });
})
.catch(err => console.error(err));
A
axetroy#18 年前

以前爬虫怎么爬,就怎么爬。

基本上都是请求,解析text,node jquery 选择,输出。

时尚一点的,还可以用无头浏览器 From Noder

参与回复

登录后即可参与回复。登录