开发者

Using javascript to get html elements from another website?

Let's say I want to write a script to go to a certain Wikipedia page, and then copy and save some text/images into a database (jquery ajax or whatever).

How do I开发者_如何学C get my script to connect to a website like http://en.wikipedia.org/wiki/Rock_and_roll and then start doing stuff like:

var body_text = document.getElementById(....); 

Hope I explained my goal well enough.

Cheers.


You cannot do something like that due to cross domain security issues


It's true you cannot do what you need using JavaScript from a browser, but it can be done using server-side JavaScript. Take a look at nodejs.org for an example of server-side JavaScript programming.


Its not possible just with browser based JavaScript, but you can use YQL. With yql you can query (theoretically) every website, and get the result as jsonp in your browser.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜