[英]how to scrape a list of data from a url using jquery
I need to scrape a json data from this url: https://www.google.com/finance/info?q=NSE:NIFTY using jquery. 我需要使用以下网址从以下网址中抓取json数据: https : //www.google.com/finance/info? q = NSE:NIFTY。 once its scarped i need to pass those value from respected key to a real time updating html table. 一旦担心,我需要将这些值从受尊敬的键传递给实时更新的html表。 i am really very new to this.. so please anyone can helping me out to solve this issue. 我对此真的很陌生。.所以请任何人都可以帮助我解决这个问题。
I tried to solve the same problem with ajax also.i am very new to this front end work so please help me out for solve this issue. 我也尝试用ajax解决相同的问题。我对这个前端工作还很陌生,所以请帮我解决这个问题。
The url returns a JSONP
object. 网址传回JSONP
物件。 You can use the ajax
function of jQuery to receive the data as an javascript object and do further work with it ... 您可以使用jQuery的ajax
函数将数据作为javascript对象接收并对其进行进一步的处理...
$.ajax({
url: "https://www.google.com/finance/info?q=NSE:NIFTY",
dataType: "jsonp",
success: function(response) {
if (response.length) {
for (i = 0, l = response.length; i < l; i++) {
// example, log property 't' of each entry to the console
console.log(response[i].t);
}
}
}
});
You will have to go through the data and generate the html for it. 您将必须浏览数据并为其生成html。
You can use the getJSON
function of jquery to fetch the data 您可以使用jquery的getJSON
函数来获取数据
$.getJSON('https://www.google.com/finance/info?q=NSE:NIFTY&callback=?', function(data){
console.log(data[0]);
});
Since its a jsonp
we need to add the callback
param in the url 由于它是一个jsonp
我们需要在url中添加callback
参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.