can jquery read the dom elements of external pages?

后端 未结 2 1832
轻奢々
轻奢々 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 22:58

    I think you cannot access other domains' content with javascript due to security reasons. At least in secure browsers...

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题