How to get html source code from external url

后端 未结 3 695
忘掉有多难
忘掉有多难 2020-12-06 07:03

How can I get html source code from an external web page?

Something like: getHtml(\'http://google.com\');.

I\'ve tried to get content of iframe

相关标签:
3条回答
  • 2020-12-06 07:28

    i think using javascript xmlhttprequest with setRequestHeader('content-type','xml/text') and the url what u need it will return the responseText as the html of the page

    0 讨论(0)
  • 2020-12-06 07:36

    With javascript, getting the file contents from another domain is not allowed in many browsers for security reasons. In php, you'd have to utilize curl.

    For a workaround, you can make a php script with curl on your local domain and call that with javascript.

    0 讨论(0)
  • 2020-12-06 07:41

    Cross domain? not possible without a server process. If you are on windows and can use HTA you can use the iframe

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