can jquery read the dom elements of external pages?

后端 未结 2 1834
轻奢々
轻奢々 2021-01-23 22:09

Is it possible to read and parse the dom elements of third party websites like cnn.com (for e.g) so that I can get the div, a, p tags and read the position and size information?

2条回答
  •  深忆病人
    2021-01-23 23:06

    No, you will be blocked by the Same Origin Policy, which restricts one site from accessing another on a different domain. You could set up a server-side script, in your preferred language, which would fetch the website on behalf of your JavaScript code, but this is more complex than just using AJAX to request the page.

提交回复
热议问题