我正在开发一个简单的Web报废Web应用程序,并以正确的格式在网页上显示提取的结果,并将其存储在文本文件中。我是Node JS的新手。我在main.js中编写的基本代码如下:
///* global sitehead */
const request = require('request');
const cheerio = require('cheerio');
const response = require('response');
const fs = require('fs');
//const writeStream = fs.createWriteStream('index');
// Write Headers
request('http://play.google.com/store/apps/details?id=com.whatsapp', function(error, response, html){
if (!error && response.statusCode == 200) {
const $=cheerio.load(html);
const sitehead=$('.AHFaub');
const img=$('.xSyT2c');
const title=$('title');
const devBy=$('.T32cc ');
console.log('Page Title: ', title.text());
console.log('App Name: ', sitehead.text());
console.log('Image Url: ', img.html());
console.log('App Name: ', devBy.text());
// console.log('App Name: ', sitehead.text());
}
});
//const http=require('http')
//const server=http.createServer((function(request,response)
//{
//
// response.writeHead(200,{"Content-Type" : "text/html"});
// response.write('<html>zaaa</html>');
// response.end("Hello World\n");
//
//
//
//}));
//server.listen(7002);