我可以把youtube上的视频从youtube上删除,但我无法将这些链接转换成mp3文件。我真的很感激你的帮助,因为我已经在这个问题上沉默不语了一段时间。谢谢您。这是我的密码,
var request = require('request'),
cheerio = require('cheerio'),
mysql = require('mysql');
var video_list = new Array();
var video = new Object();
var req_comp = false;
var con = mysql.createConnection({
host: "127.0.0.1",
user: "root",
password: "",
database: "anchor"
});
con.connect(function(err) {
if (err) {
throw err;
}
else {
request('https://www.youtube.com/results?search_query=motivational+video', function(err, resp, body) {
var $ = cheerio.load(body);
var counter = 0;
$('a').each(function() {
var title = $(this).attr('title');
var url = "youtube.com" + $(this).attr('href');
if (title && url.substring(11, 17) == "/watch") {
video = {
video_id : counter,
video_url : url,
video_title : title
};
video_list[counter] = video;
counter += 1;
}
});
req_comp = true;
console.log(req_comp + " " + video_list.length);
var counter = 0;
while (video_list[counter]) {
var sql = "INSERT INTO content (video, title) VALUES ('" + video_list[counter].video_url + "', '" + video_list[counter].video_title + "');";
con.query(sql, function (err, result) {
if (err) {
throw err;
}
});
counter++;
}
});
}
});
暂无答案!
目前还没有任何答案,快来回答吧!