SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to go to a diffrent page and read it

    Hi I have a question regarding how to go to a website and scan it for hyperlinks and save them in a variable. I want to do something like this

    Code:
      Var everythingAdiffrentPageContains = //Go to some link exwww.msn.se and store it in this variable
    
       var pageLinks  = []; 
     var anchors    = everythingAdiffrentPageContains.getElementsByTagName('a');  
        var numAnchors = anchors.length;
        for(var i = 0; i < numAnchors; i++) {     
             pageLinks.push(anchors[i].href); 
        }
    In other words I would like to go to some site and store all that sites Hyperlinks in an array, how would you do this in javascript?


    Im not trying to connect to another domain. Im trying to connect to another apache webserver inside my lan that hosts a website that I would like to scan for links.

    Thanks

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    That type of behaviour is no longer allowed to be performed via scripting where it's on a different domain.

    When being done locally, you can load the page in to an iframe and use the contentDocument of the iframe to access it.

    Otherwise, you'll want to investigate a server-side solution for that, perhaps using curl
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Location
    Oskarshamn, Sweden
    Posts
    83
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    YQL might be an option.


Tags for this Thread

Bookmarks

Posting Permissions

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