简体   繁体   中英

Javascript to modify html from external site

I've been researching for about 2 days now and am all out of ideas. I'm new to javascript but from what I have read it seems that my problem has to do with cross-site scripting rules/precautions. My goal is simple make a website based on an external site (which I have no control over). I want to use javascript or some other method to load a website's html and then remove tags etc. I looked at ajax but ran into issues with same-domain restrictions. I tried a "hack" by including the website in a hidden iframe and trying to access the code that way but sandboxing seems to prevent that. I really want to do this with web based techniques. Any advice or tips on how to handle this (or is it impossible)?

The easiest way is to have a simple server-side process that will make the request to the other site for you, retrieve its HTML and return that to you.

Then you just make an AJAX request to your server side method and when it returns, you will have access to the other website's HTML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM