第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

每個視頻后面多了幾個字

為什么會有一個’開始學(xué)習(xí)‘啊

正在回答

2 回答

a里面有個button標(biāo)簽,隱藏的,爬下來可以看到

<button class="r moco-btn moco-btn-red preview-btn">開始學(xué)習(xí)</button>


0 回復(fù) 有任何疑惑可以回復(fù)我~
var?http?=?require('http');
var?cheerio?=?require('cheerio');
var?url?=?'http://idcbgp.cn/learn/348';
var?chapter,chapterTitle,videos,chapterData,video;

function?filterChapters(html)?{
	var?$?=?cheerio.load(html);
	var?chapters?=?$('.chapter');

	var?courseData?=?[];
	chapters.each(function?(item)?{
		chapter?=?$(this);
		chapterTitle?=?chapter.find('strong').text().trim().replace(/\s+/g,'?');
		chapterTitle?=?chapterTitle.split('?')[0]+'?'+chapterTitle.split('?')[1];
		videos?=?chapter.find('.video').children('li');
		chapterData?=?{
			chapterTitle:?chapterTitle,
			videos:?[]
		};
		videos.each(function(item)?{
			video?=?$(this).find('.J-media-item');
			var?videoTilte?=?video.text().replace(/[\s]/g,'').replace('開始學(xué)習(xí)',?'');
			var?id?=?video.attr('href').split('video/')[1];

			chapterData.videos.push({
				title:?videoTilte,
				id:?id
			})
		});

		courseData.push(chapterData);
	})

	return?courseData;
}

function?printCourseInfo(html)?{
	var?res?=?'';
	html.forEach(function(item)?{
		res?+=?'標(biāo)題:'?+?item.chapterTitle?+?'\n';
		item.videos.forEach(function(video)?{
			res?+=?'??【'?+?video.id?+?'】'?+?video.title?+?'\n';
		})
	})

	console.log(res);
}

http.get(url,?function(res)?{
	var?html?=?'';

	res.on('data',?function?(data)?{
		html?+=?data;
	})

	res.on('end',?function?()?{
		var?courseData?=?filterChapters(html);
		printCourseInfo(courseData);
	})
}).on('error',function?()?{
	console.log('出錯');
})

這是我寫的代碼

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消
進(jìn)擊Node.js基礎(chǔ)(一)
  • 參與學(xué)習(xí)       219294    人
  • 解答問題       982    個

本視頻教程帶你揭開Node.js的面紗,帶你走進(jìn)一個全新世界

進(jìn)入課程

每個視頻后面多了幾個字

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號