Firstly I am a newbie and I want a code for Fetching html string from another webpage and use it in my own webpage let me explain briefly by Dummy Examples.
Mysite.com/A.html
<body>
<!---My Script Goes here--->
</body>
XYZ.COM/B.html Another site
<body>
<form id="Form1" action="https://test.com/" method="Post">
Some Text or Something Else</form>
</body>
I want to get or extract action attributes value I.e. https://test.com of XYZ.com/B.html by Script of Mysite.com/A.html page with using only javascript. So I can render it by my use.
Plz help I am frustrated of this.
2
Answers
<form>
is for forms, not for fetching. If you wanna show some webpages inside your webpage, use<iframe>
If however you wanna fetchstrings
of another website. Then you’ll have to learn something calledWeb Scrapping
, orWeb Crawler
.1, post, you just can set you from action to https://test.com/B.html, when submit the form data will post to test.com and page will redirect to as well
2, Fetching html string, by default user can’t read the data from other domain. if test.com no own by you, you need hack the test.com web server, add the HTTP header named: Access-Control-Allow-Origin
see https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
BTW: if you just want get the text for you self, you just can use tool for post the data by HTTP protocol, then read the response, for example: