Using JQuery to get the HTML from another website: Possible? Legal?

后端 未结 5 1880
猫巷女王i
猫巷女王i 2021-02-04 14:40

I am trying to get HTML code from a webpage that is not in the same domain. The html text is parsed & summarises a recipe(recipe name, main ingredients, no. of steps) found

5条回答
  •  青春惊慌失措
    2021-02-04 15:42

    No, this will not work from client-side JavaScript. The browser prevents it for security reasons. You would need to make ajax calls to a local server-side script (PHP, for example) which would then fetch the content (via cURL, for example) and return the HTML you want.

提交回复
热议问题