Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #29023 > unrolled thread

calback returning null values

Started bywasiu razak <razakwasiu@gmail.com>
First post2015-12-18 10:43 -0800
Last post2015-12-18 20:55 +0100
Articles 2 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  calback returning null values wasiu razak <razakwasiu@gmail.com> - 2015-12-18 10:43 -0800
    Re: calback returning null values "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-12-18 20:55 +0100

#29023 — calback returning null values

Fromwasiu razak <razakwasiu@gmail.com>
Date2015-12-18 10:43 -0800
Subjectcalback returning null values
Message-ID<e234ccf2-740a-4a1f-b2f9-8ef19cf95f8c@googlegroups.com>
hi am using the x ray library to scrapper a website ,with crawling feature using callback mechanism , but calling it without obj.moreDetail return values as expected

var Xray = require('..');
var x = Xray();


var html = 'http://www.myjoyonline.com/news.php';

function getter(url ,callback) {
	setTimeout(function() {
		x(url, ['div.side1 div.storypane p'])(function(err, obj) {
			callback(obj);
		});
	}, 500);
}

x(html, 'ul.opinion-listings li', [{
	title: '.head .title a',
	desc: '.info',
	date: '.head',
	img: '.image-inner a img@src',
	url: '.head .title a@href'
		// fullStory: x('.head .title a@href', ['div.side1 div.storypane p']),
}])(function(err, obj) {
	for (var i = 0; i < obj.length; i++) {
		console.log(obj[i]);
		getter(obj[i].url,function(results) {
			var fullStory= results;
			obj[i].moreDetails = fullStory;
			console.log(obj[i]);
		});
	}

});

return null values only 

[toc] | [next] | [standalone]


#29024

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2015-12-18 20:55 +0100
Message-ID<XnsA574D4D761E2Beejj99@194.109.6.166>
In reply to#29023
wasiu razak <razakwasiu@gmail.com> wrote on 18 Dec 2015 in
comp.lang.javascript: 

> hi am using the x ray library 

This NG is not a helpdesk for libraries.

Why do you need a library for this anyway?

It won't help you circumventing 
the same origin security feature
of modern browsers.

Better try uitside a browser,
like with cscript/wscript or serverside jscript:

function getUrl(url) {
  var http = new ActiveXObject("MSXML2.ServerXMLHTTP");
  http.open("GET",url,false);
  http.setRequestHeader("User-Agent", "Mozilla/5.0");
  http.send();
  return http.responseText;
};


> to scrapper a website ,with crawling
> feature using callback mechanism , but calling it without obj.moreDetail
> return values as expected 
> 
> var Xray = require('..');
> var x = Xray();
> 
> 
> var html = 'http://www.myjoyonline.com/news.php';
> 
> function getter(url ,callback) {
>      setTimeout(function() {
>           x(url, ['div.side1 div.storypane p'])(function(err, obj) {
>                callback(obj);
>           });
>     }, 500);
>}
> 
> x(html, 'ul.opinion-listings li', [{
>      title: '.head .title a',
>      desc: '.info',
>      date: '.head',
>      img: '.image-inner a img@src',
>      url: '.head .title a@href'
>           // fullStory: x('.head .title a@href', ['div.side1
>           div.storypane p']), 
>}])(function(err, obj) {
>      for (var i = 0; i < obj.length; i++) {
>           console.log(obj[i]);
>           getter(obj[i].url,function(results) {
>                var fullStory= results;
>                obj[i].moreDetails = fullStory;
>                console.log(obj[i]);
>           });
>     }
> 
>});
> 
> return null values only 
> 
> 
> 



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web