2

I'm trying build a website for the purpose of helping users to analyse links of a website which they submit to my website.

Steps like this:

  1. User paste a website link into my "search box".
  2. JS download the source html content and post to my server.
  3. My server show analysis result to user.

But actually JS cannot load html source of others website. How could I solve it?

I have this JS code already:

function dosubmit() {
    var url = document.getElementById("url-input").value;
    $.ajax({
        url:url,
        crossOrigin: true,
        success: function(response){
            alert(response);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            alert(errorThrown);
        }
    })
}
Robin Mackenzie
  • 18,801
  • 7
  • 38
  • 56
orlando
  • 21
  • 4
  • Try this server side instead. – Jai Dec 10 '16 at 06:33
  • My server would be blocked by target websites after many visit times executed. – orlando Dec 10 '16 at 06:36
  • What you have tried so far? show your code. – abpatil Dec 10 '16 at 06:40
  • How do you conclude that your server would be blocked? How many times do you expect people to submit the same site? You will also need a disclaimer as some sites may respond differently based on factors such as user agent. To allow for this, they should also have the option for file upload or source input. Such as on [http://validator.w3.org/](http://validator.w3.org/) – Darren H Dec 10 '16 at 09:11
  • To respond more specifically to your question however, the only way to deal with this in javascript is to [enable CORS](http://enable-cors.org/). This would involve your users doing work on their server which if done incorrectly could render their site open to new security holes. It would also likely be out of the scope of understanding (and access) of someone who needs to have their HTML markup checked. So I'd seriously recommend against that. – Darren H Dec 10 '16 at 09:14

0 Answers0