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


Groups > comp.lang.javascript > #29024

Re: calback returning null values

Newsgroups comp.lang.javascript
Subject Re: calback returning null values
From "Evertjan." <exxjxw.hannivoort@inter.nl.net>
References <e234ccf2-740a-4a1f-b2f9-8ef19cf95f8c@googlegroups.com>
Date 2015-12-18 20:55 +0100
Message-ID <XnsA574D4D761E2Beejj99@194.109.6.166> (permalink)

Show all headers | View raw


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)

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

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

csiph-web