Tuesday, 5 July 2016

nodejs use 'request' and 'cheerio' access blogger, returns "DP live"

var cheerio = require('cheerio');
var jsdom = require('jsdom');
var request = require('request');

function read() {
    request({
        uri: 'http://xxxxx/threadxxx.php?fid=xxxx'
    }, function(err, response, body) {
        jsdom.env(
            body, ['http://code.jquery.com/jquery-1.6.min.js'], function(err, window) {
                console.dir(body);



solution:

function read() {
    request({
        uri: 'http://xxxxx/threadxxx.php?fid=xxxx',
        headers: {
            'User-Agent': 'request'
          }
    }, function(err, response, body) {
        jsdom.env(
            body, ['http://code.jquery.com/jquery-1.6.min.js'], function(err, window) {
                console.dir(body);


https://cnodejs.org/topic/5426c9897321d5482c158715

No comments:

Post a comment