javascript - Jquery - how to make this code work? (extracting info from another website) -


i've found nice piece of code seems work, have difficulites adapt needs (never used jquery, basics of java). able figure out part of it, haven't succeed make work.

the website i'm trying extract info from: here. want access value of child (h2) present in div class="cash" (the amount of money raised).

i'm trying adapt code (jfiddle):

var url='http://query.yahooapis.com/v1/public/yql?q=select * html url=\'http://stackoverflow.com/\' , xpath=\'//div[@id="question-mini-list"]//h3//a\'&format=json&callback=?';  $.getjson( url, function(data){     $.getjson( url, function(data){         $.each(data.query.results.a, function(){                $('body').append('<div><a href="http://stackoverflow.com'+this.href +'">'+this.content+'</a></div>')            })     console.dir(data.query.results) }) 

i've changed url into:

var url='http://query.yahooapis.com/v1/public/yql?q=select * html url=\'http://rycerzeiksiezniczki.pl/kids/agatka/?lang=pl' , xpath=\'//div[@class="cash"]//h2\'&format=json&callback=?'; 

(replaced website url , xpath). played rest of code (url, , this.stuff), no success (fiddle).

what should change make work?

i think escaped url string wrong: '..../?lang=pl'... --> '..../?lang=pl\'...

the ' after lang query parameter should escaped \'.

additional xpath query not precise enough: should work:

var url='http://query.yahooapis.com/v1/public/yql?q=select * html url=\'http://rycerzeiksiezniczki.pl/kids/agatka/?lang=pl\' , xpath=\'//div[@class="row cash"]//h2\'&format=json&callback=?';   $.getjson( url, function(data){     $.each(data.query.results, function(){            $('body').append('<div><a href="http://rycerzeiksiezniczki.pl/kids/agatka/?lang=pl'+'">'+this.content+' ' + this.strong + '</a></div>')                })  }) 

the tag want extract contains classes row and cash.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -