Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2013
    Posts
    23
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Arrow Getting html from a remote site

    Is there anyway to get part of html file on a remote site, retrieve and use as a variable.

    Regards

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,849
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,277
    Thanks
    10
    Thanked 581 Times in 562 Posts
    sure, just use the yql console

    Code:
    <body>
    <div id=output></div>
    
    <script>
    function print(data){
      output.innerHTML=data.query.results.a.map(function(a){
         return a.content && a.content.link(a.href) || "";
      }).filter(String).join("<br />");
    }
    </script>
    <script src="http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http%3A%2F%2Fwww.voanews.com%2F%22%20and%0A%20%20%20%20%20%20xpath%3D'%2F%2Fdiv%5B%40class%3D%22columnInner%22%5D%2Fh4%2Fa'&format=json&diagnostics=true&callback=print"></script>
      
      </body>
    produces:

    Code:
    At Least 30 Killed in Pakistan Earthquake
    Cambodia’s Hun Sen Re-Elected Despite Opposition Boycott
    N. Korea Appears Capable of Making Nuclear Weapon
    Russia Says Greenpeace Activists Will Be Prosecuted
    Former FBI Agent to Plead Guilty to Leaking Secret Information to Journalists
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •