I need to automate a script that is mostly VBScript, but has some JScript in it to test JSON objects as well as a JSON parser that is also written in Jscript. Also, we have a bunch of INCLUDE files (I could do an ExecuteGlobal on them, but there are a bunch of hurdles there too). Normally I would just take all my Classic ASP code, make adjustments for VBS files, save, and set up a task on the server to execute. The issue is the mixed JScript.
Is there a way to execute a classic ASP file automatically that I am not aware of? I could redirect the first visitor of the day or something to a page and then once the page is done, redirect them to the requested page, but that's really a hack. But, maybe a hack is the only way to do this.
Any help would be appreciated, thank you!
Dennis
I figured out the best way to do this is with a XML HTTP get request on the page from a VBS file that I set up as a scheduled task.
Set objXML = CreateObject("MSXML2.ServerXMLHTTP.6.0")
objXML.open "GET", "Full-URL-HERE", false
objXML.send()
sResponse = objXML.responseText
Set objXML = Nothing
Then Full-URL-HERE is the URL to the page that you wanted to automate.
Related
I have little to none programming experience and I just started learning Python two weeks ago it was a pain running under windows (e.g. environment variable etc something I didn't really know what it is until two weeks ago).
I am using seleniumto try to web scrape information.
basically the url(mainly jscript) pages changes incrementally:
e.g.
http://sssss.proxy.sssss/sample#/detail/0/1
http://sssss.proxy.sssss/sample#/detail/0/2
http://sssss.proxy.sssss/sample#/detail/1/1
http://sssss.proxy.sssss/sample#/detail/1/2
http://sssss.proxy.sssss/sample#/detail/2/1
http://sssss.proxy.sssss/sample#/detail/2/2
http://sssss.proxy.sssss/sample#/detail/50/1
http://sssss.proxy.sssss/sample#/detail/50/2
I want to pragmatically and systemically webscrape specific content(find by xpath) under each page and its subpage. However, I don't know how loop works (e.g. for i to xxx) in this case because every url has to be "get" by browser web driver. (does it mean the loop will initiate the browser to open every single page or will it happen within python shell like in request package)
There are method for scraping content for url that is fixed. But in my case the url does changes so I assume it can be done differently.
Please enlighten me
With thanks,
Iverson
Is multithreading possible using vbscript. i have to form fill a web page in multiple browsers/tabs, so that, i hope can reduce the completion time. Please suggest.
Vbscript does not natively have any methods for launching separate threads although if you try then it's more of "emulation" of multi-threading than anything else
You can check this documentation
To open a url in vbscript you can try something like this:-
set wShell = CreateObject("Shell.Application")
wShell.Open "C:\temp\abc.txt"
I wrote vbscript inside my html file for my site and I can't get it to work. I know it only works in internet explorer as thats the common answer I see people write with this issue. I am able to get basic vbscript working, but when trying to use filesystemobjects to open a text file nothing happens. Code being used is below.
<Script type="text/vbscript">
Dim fsobj, objtxt, thearr
Set fsobj = CreateObject("Scripting.FileSystemObject")
Set objtxt = fsobj.OpenTextFile("./subfolder/foo.txt", 1)
thearr = split(objtxt.readline, ",")
document.write(thearr(0) & " and " & thearr(1))
</script>
I get the code to work when saving with asp extension but not when I save as html, is there a way to get it to work with only using the html extension? If not does someone have an explanation as to why scripting filesystemobject without the asp extension doesn't work? I seem to can't search for the answer I'm looking for.
When you were using the FileSystemObject from an ASP page, then you were manipulating the file-system of the server. This is permitted.
However, when you use the code above, you are executing the code on the client. It is not permitted to access the clients file-system from inside Internet Explorer, as it would have serious security implications. The technical term is "sandboxing".
If you need to interact with the file-system on the client machine, you will need to use a technology such as ActiveX.
When you run the script as client script, it would try to access the file from the client computer, not the server. The file isn't there, and even if it was, your script would not be allowed to access it.
You should consider using HTML Applications by renaming your file with a .hta suffix.
An HTA executes without the constraints of the internet browser security model; in fact, it executes as a "fully trusted" application.
HTML files running inside internet browsers are considered as "untrusted" because the code comes from the internet, and is generally considered as "untrusted" as such the browser enforces a tight security model that prevents those HTML pages gaining access to your computer, which is why the FileSystemObject is unable to open the text file. However, as a HTA it is no longer being run by your browser, but via Microsoft's MSHTA application which grants your script full trust.
For more information see HTML Application - Wikipedia.
I'm trying to write a script to automate a repetitive task I currently do manually. I would like to log in to a site remotely and inspect the returned page.
I've been doing this by sending a direct POST request (the site is PHP, I'm pretty sure it's Joomla) with my login details and data for the other fields of the form from the front page, but I'm getting either sockaddrinfo errors on the Net:HTTP Ruby library when I try a HTTP.post() (with data as a param=val1¶m2=val2 string), and a rejected redirect to home page if I use HTTP.post_form (using a Hash)
I'm willing to do this in any language, really, I just picked Ruby since it's a favorite for quick scripting. If you have any ideas in bash, Python, etc. I'd be happy to try it.
I've tried variations on some examples, to no avail. Have any of you tried something like this with success? Any stumbling blocks we beginners run into frequently?
Thanks for your time ^_^
-Paul
Try mechanize:
http://mechanize.rubyforge.org/mechanize/EXAMPLES_rdoc.html
Have a look at mechanize (Python) which is written with your problem in mind:
import re
from mechanize import Browser
br = Browser()
br.open("http://www.example.com/")
# follow second link with element text matching regular expression
response1 = br.follow_link(text_regex=r"cheese\s*shop", nr=1)
I'm fairly new to JavaScript.
Given a local machine's folder path (Windows), I was wondering how you can extract the names of all the possible folders in the current path, without the knowledge of how many folders there are or what they are called.
Thank you very much in advance.
Here is a little script to get you started with FileSystemObject in conjuction with JScript:
var fso = new ActiveXObject("Scripting.FileSystemObject");
var shell = new ActiveXObject("WScript.Shell");
var path = "%ProgramFiles%";
var programFiles = fso.GetFolder(shell.ExpandEnvironmentStrings(path));
var subFolders = new Enumerator(programFiles.SubFolders);
while (!subFolders.atEnd())
{
var subFolder = subFolders.item();
WScript.Echo(subFolder.Name);
subFolders.moveNext();
}
Call that with csript.exe on the command line:
cscript subfolders.js
The Windows Script 5.6 Documentation holds all the details you need on this topic (and many others). Download it and have it around, it is really helpful. On Windows systems, a little knowledge of FileSystemObject and it's relatives really can save the day.
You cannot do this via Javascript in a browser as the JS doesn't have that kind of access to the file system from a browser.
Assuming the script will execute in a context where it makes sense to try and access the local hard drives (e.g. in cscript or classic ASP), your best bet is the FileSystemObject.
If you're executing JavaScript in a web browser then you can't, because in this scenario JavaScript has no access to the local file system for security reasons.