Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAndrew Young
Courses Plus Student 639 PointsGet value from a aspx website using cheerio
I want to get a value in this website
But it's a aspx website and the value will change time by time so it's generate by script (i think) so here's the point
I wrote a script (see below):
var express = require('express');
var fs = require('fs');
var request = require('request');
var cheerio = require('cheerio');
var app = express();
app.get('/scrape', function(req, res){
res.writeHead(200, {'Content-Type': 'text/html'});
res.write("<meta charset=\"utf-8\"><h1>");
// Let's scrape Anchorman 2
url = 'https://taqm.epa.gov.tw/taqm/aqi-map.aspx';
request(url, function(error, response, html){
if(!error){
var $ = cheerio.load(html);
// console.log(cheerio.load(html));
var title, release, rating;
var json = { title : "", release : "", rating : ""};
$('.aqiArea').filter(function(){
var data = $(this);
title = data.children().first().text().trim();
res.write(title);
})
res.write(": ")
$('#lb_AQI.right').filter(function(){
var data = $(this);
dis = data.first().text().trim();
res.write(dis);
})
}
// res.send('Check your console!')
res.end("</h1>");
})
})
app.listen('8081')
console.log('Magic happens on port 8081');
And with this code it can only get the source of aspx but can't get the current value
So how can I get the current value of the ASPX website using node.js?
1 Answer
Benjamin Kuijs
17,022 PointsHi Andrew, I've been asked to answer this question. Your level of coding is way above mine.
Unfortunately i am unable to help..
Good luck!
Kind regards, Benjamin
Andrew Young
Courses Plus Student 639 PointsAndrew Young
Courses Plus Student 639 PointsCan you link a link to your question??
Thx!
Andrew Young
Courses Plus Student 639 PointsAndrew Young
Courses Plus Student 639 Points@Benjamin I also ask here is you want you can also follow here
Stackoverflow
Quora