Reputation: 15002
I wrote a simple example in Python. the goal is to fetch the HTML and use "beautifulsoup"(html parser library) to parse the data I want. The tools I used as following 1. curl : to fetch specific url resource 2. beauifulsoup : make me parse the complex html more easier
Now, I want to achieve the goal by pure javascript, Because I want the to put the functionality on the my web site, however if put the computation tasks on Server side is heavy for server, so I want to pass the tasks to the client-side.
Is there any good way (some libraries?) to achieve the goal quickly?
Many thanks in advance
Upvotes: 1
Views: 200
Reputation: 3167
You cannot fetch HTML from other domains using JavaScript. It's intentionally disallowed for security reasons.
You could write a simple proxy on the server-side and then fetch the HTML through the proxy. That would free the server from any heavy computation you need to do, even if the load isn't completely on the browser.
Or, if you have control of the code on the other site, you could use JSONP as stated in Hilmi's comment.
Upvotes: 2