-1

How to get given URL's page source in Javascript.

Suppose i give window.open("https://www.google.co.in"); then it should go to above URL and take page source of google.com which can be save in file. I am using JS in HTML.

5
  • 1
    This can't be done in javascript. You need to do this on the server. Commented Jul 10, 2014 at 14:30
  • I think a better question is why do you want to do this? If I'm understanding correctly, it sounds like you want to get the source of the page that your user is attempting access and replacing it with a copy you've pulled yourself. But why?? This is what the browser is designed to do. Commented Jul 10, 2014 at 14:33
  • @ Smeegs how to do it using other lang with the help of JS Commented Jul 14, 2014 at 7:46
  • @esqew actually i wanted to find out all links in given page a save them in a file Commented Jul 14, 2014 at 7:48
  • window.open("google.co.in"); var sourceObj = "view-source:" + window.location.href; Commented Jul 14, 2014 at 7:50

1 Answer 1

0

I you want a cross-domain solution (like your example for google), you can't.

See How to get html source code from external url

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.