Skip to content

Instantly share code, notes, and snippets.

@C0nw0nk
Last active November 14, 2022 05:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save C0nw0nk/7220ca4569eed29a2512f5ed1b2795a2 to your computer and use it in GitHub Desktop.
Save C0nw0nk/7220ca4569eed29a2512f5ed1b2795a2 to your computer and use it in GitHub Desktop.
Batch file to run javascript open website grab contents
@if (@This==@IsBatch) @then
@echo off & setLocal EnableDelayedExpansion & CHCP 65001 >NUL
:: Copyright Conor McKnight
:: https://github.com/C0nw0nk/
:: https://www.facebook.com/C0nw0nk
:: Execute Javascript without needing to install anything
:: store javascript output in batch file variable
set site="https://www.youtube.com/watch?v=frFdisA68Lo&t=32s"
for /f "tokens=*" %%a in ('
cscript //nologo //E:JScript ^"%~dpnx0^"^ %site%
') do set "javascript_output=!javascript_output!%%a"
echo !javascript_output!
pause
exit /b
@end
//Javascript
// Instantiate the needed component to make url queries
var http = WScript.CreateObject('MSXML2.ServerXMLHTTP.6.0');
// Retrieve the url parameter
var url = WScript.Arguments.Item(0)
//Make the request
http.open("GET", url, false);
http.send();
//If we get a OK from server (status 200), output to console
if (http.status === 200) WScript.Echo(http.responseText);
//Close script
WScript.Quit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment