How to get html source code from external url

后端 未结 3 703
忘掉有多难
忘掉有多难 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条回答
  •  萌比男神i
    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.

提交回复
热议问题