VBScript: Get Source Code of a Web Page

This method will work only in Internet Explorer. Also, this is only the way to get cross-domain source code. However, you can use this code externally also.


<script type="text/vbscript">
Dim url, src, http
Set http = ObjCreate("winhttp.winhttprequest.5.1")
http.open("GET",url)
http.send()
src = http.Responsetext
document.write('<textarea>'+src+'</textarea>')
</script>

If you want to use this code externally, then you should save it as name.vbs. But you should remove the last line. Instead, you can try alternate ways like msgbox, filewrite, etc to show the output. For example, replace last line by this:

MsgBox(src)

This will show the source code directly in a messagebox.

No comments:

Post a Comment

Thank you for commenting. Please keep visiting.