使用Javascript从其他网站收集数据 [英] Collect data from another site using Javascript

查看:105
本文介绍了使用Javascript从其他网站收集数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个必须从其他网站提取数据的计算器。

I am trying to build a calculator that will have to pull data from another site.

例如,如果我网站上的用户选择货币BRL,我想从此网站。我该怎么做?!

For example, if the user on my site selects the currency "BRL", I want to collect the rate "3.04" from this site. How can I do this?!

请帮忙。谢谢!!

推荐答案

你不能这样做是因为您创建load.php的网站上的安全限制BUT
文件包含以下代码:

You cannot do it because the security restriction BUT on your site you create load.php file with the code:

<?php
$content = file_get_contents("http://dev.zionsfx.com/FXLiveRateStream4.asp");
echo $content;

和js code

$.ajax({
        type: "POST",
        url: "http://yourSiteUrl/load.php",
        }).done(function( result ) {
         var tab = $(result).find('tr[title="Brazilian Real"]') .find('td:eq(1)');
  console.info(tab.text())
        });

代码不是很好但它可以满足您的需求。所以你可以在空闲时间内改善它

the code is not really nice but it does what you wanted. So you can improve it in your free time

这篇关于使用Javascript从其他网站收集数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆