Get HTML code using JavaScript with a URL

前端 未结 5 1358
鱼传尺愫
鱼传尺愫 2020-12-01 14:31

I am trying to get the source code of HTML by using an XMLHttpRequest with a URL. How can I do that?

I am new to programming and I am not too sure how can I do it wit

5条回答
  •  旧时难觅i
    2020-12-01 14:45

    Edit: doesnt work yet...

    Add this to your JS:

    var src = fetch('https://page.com')
    

    It saves the source of page.com to variable 'src'

提交回复
热议问题