Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8378047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:49:58+00:00 2026-06-09T15:49:58+00:00

So I have been trying to scrape a websites data.asp file (which seems to

  • 0

So I have been trying to scrape a websites data.asp file (which seems to be formatted in json) into my website to be displayed as a chart I seem to be able to get the json data but will not display as a chart in either googles chart API or fusioncharts I am not sure what I am doing wrong although in the examples on google and fusioncharts there json data is formatted differently would i have to change mine to meet that? and how would i do this to make sure that as the data.asp file is updated on the external website it is updated on mine also?

EDIT: Is there an easier way to get the data (aswell as on update) into a chart?

        <meta charset="utf-8">
        <title>Olympic Results</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">

        <!--styles -->
        <link href="css/bootstrap.css" rel="stylesheet">
        <style type="text/css">
          body {
            padding-top: 60px;
            padding-bottom: 40px;
          }
          .sidebar-nav {
            padding: 9px 0;
          }
        </style>
        <link href="css/bootstrap-responsive.css" rel="stylesheet">

        <!--HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        <?php
            if(!function_exists("curl_init")) die("cURL extension is not installed");
            $ch = curl_init("http://hosted.stats.com/olympics/medals_widget/data.asp?country=NZL");
            //Configuring curl options 
            $options=array(CURLOPT_RETURNTRANSFER => true, 
                           CURLOPT_HTTPHEADER => array('Content-type: application/json'));
            //Setting curl options
            curl_setopt_array($ch, $options);
            $pageData = curl_exec($ch);
            curl_close($ch); 
            //Cache the channel file 
            $cache_expire = 60*60*24*365;
            header("Pragma: public");
            header("Cache-Control: max-age=".$cache_expire);
            header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$cache_expire) . ' GMT');
        ?>
        <script type="text/javascript" src="Charts/FusionCharts.js"></script>

      </head>
      <body>
        <div class="navbar navbar-fixed-top">
          <div class="navbar-inner">
            <div class="container-fluid">
              <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </a>
              <a class="brand" href="#">Olympic Results</a>

              <div class="nav-collapse">
                <ul class="nav">
                  <li class="active"><a href="#">Home</a></li>
                </ul>
              </div><!--/.nav-collapse -->

            </div>
          </div>
        </div>

        <div class="container-fluid">
        <div id="chartContainer">FusionCharts XT will load here!</div>          
        <script type="text/javascript">

        <!--       
          var data = <?php echo $pageData; ?>;
          document.write(data);
          var myChart = new FusionCharts( "Charts/Column3D.swf", "myChartId", "400", "300", "0", "1" );
          myChart.setJSONData(data);
          myChart.render("chartContainer");

        // -->     
        </script> 
        <?php echo("$pageData"); ?>
            <footer style="padding-top:100px;">
            <hr>
            <p>&copy; Olympic Results 2012</p>
            </footer>

        </div><!--/.fluid-container-->

        <!-- javascript -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script src="js/jquery.js"></script>
        <script src="js/bootstrap-transition.js"></script>
        <script src="js/bootstrap-alert.js"></script>
        <script src="js/bootstrap-modal.js"></script>
        <script src="js/bootstrap-dropdown.js"></script>
        <script src="js/bootstrap-scrollspy.js"></script>
        <script src="js/bootstrap-tab.js"></script>
        <script src="js/bootstrap-tooltip.js"></script>
        <script src="js/bootstrap-popover.js"></script>
        <script src="js/bootstrap-button.js"></script>
        <script src="js/bootstrap-collapse.js"></script>
        <script src="js/bootstrap-carousel.js"></script>
        <script src="js/bootstrap-typeahead.js"></script>
      </body>
    </html>

Forgot to add what the JSON looks like –

{"medals": { 
"Archery":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze":       "0", "total": "0" }], 
"Track & Field":[ { "stats_id": "83", "gold": "0", "silver": "1", "bronze": "0", "total": "1" }], 
"Badminton":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Basketball":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Beach Volleyball":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Boxing":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Diving":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Equestrian":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "1", "total": "1" }], 
"Soccer":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Fencing":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Handball":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Field Hockey":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Judo":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Modern Pentathlon":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }],
"Rowing":[ { "stats_id": "83", "gold": "3", "silver": "0", "bronze": "2", "total": "5" }],  
"Sailing":[ { "stats_id": "83", "gold": "1", "silver": "1", "bronze": "0", "total": "2" }], 
"Shooting":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Swimming":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Synchronized Swimming":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Tennis":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Taekwondo":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Triathlon":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Table Tennis":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Volleyball":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Weightlifting":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Water Polo":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Wrestling":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Cycling":[ { "stats_id": "83", "gold": "0", "silver": "1", "bronze": "2", "total": "3" }], 
"Gymnastics":[ { "stats_id": "83", "gold": "0", "silver": "0", "bronze": "0", "total": "0" }], 
"Canoe":[ { "stats_id": "83", "gold": "1", "silver": "0", "bronze": "0", "total": "1"     }] 
}}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:49:59+00:00Added an answer on June 9, 2026 at 3:49 pm

    Yes, you will need to reformat your data. Get the data, convert it to a real javascript object and iterates over it and re-create the structure in the way your APIs understand. To convert JSON to an Object you cand use $.parseJSON method of the jQuery library.

    Another thing. These data are obtained by your server and them redirected to your application?

    Edit: Here is one example:

    // this way, data is already an object
    var data = { "medals": {
        "Archery":[{
            "stats_id": "83",
            "gold": "0",
            "silver": "0",
            "bronze":  "0",
            "total": "0"
        }],
        "Track & Field":[{
            "stats_id": "83",
            "gold": "0",
            "silver": "1",
            "bronze": "0",
            "total": "1"
        }] // more data here...
    }};
    
    // if data comes this way (a String), it needs to be parsed
    var dataStr = "{ \"medals\": {" +
    "    \"Archery\":[{" +
    "        \"stats_id\": \"83\"," +
    "        \"gold\": \"0\"," +
    "        \"silver\": \"0\"," +
    "        \"bronze\":  \"0\"," +
    "        \"total\": \"0\"" +
    "    }]," +
    "    \"Track & Field\":[{" +
    "        \"stats_id\": \"83\"," +
    "        \"gold\": \"0\"," +
    "        \"silver\": \"1\"," +
    "        \"bronze\": \"0\"," +
    "        \"total\": \"1\"" +
    "    }]" + // more data here...
    "}}";
    
    console.log( data );
    
    var obj = $.parseJSON( dataStr );
    console.log( obj );
    
    traverseObj(obj);
    
    // traverses the object to see all its properties
    function traverseObj( data ) {
        for ( var key in data ) {
    
            var value = data[key];
    
            if ( $.isPlainObject( value ) ) {
    
                console.log( "**key: " + key );
                traverseObj( value );
    
            } else if ( $.isArray( value ) ) {
    
                console.log( "key: " + key );
                var values = "";
    
                for ( var i = 0; i < value.length; i++ ) {
                    var currValue = value[i];
                    if ( $.isPlainObject( currValue ) ) {
                        traverseObj(currValue);
                    } else {
                        values += currValue + ", ";
                    }
                    if ( values != "" ) {
                        console.log( " - value: " + value );
                    }
                }
    
            } else {
                console.log( "key: " + key + " - value: " + value );
            }
        }
    }
    

    Here is the fiddle: http://jsfiddle.net/davidbuzatto/MysPe/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to data scrape the current value of a stock from
Have been trying to write an awk script which processes a log file, but
Have been trying to encrypt an xml file to a string so that I
I have been trying to create a ListView which I can sort using drag
I'm trying to scrape some data off of the FEC.gov website using python for
I have been trying to scrape the 'School Notices' from this URL http://www.isleworthsyon.hounslow.sch.uk/ I
I have been trying desperately to draw some images into a view. The view
Have been trying on these codes and I want to send a email which
Have have been trying to make a validator for my xml files. I have
I have been trying to setup git for our web development team unsuccessfully. Some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.