I am trying to use WinSCP to access a remote HTML file, and I do have root permission. However, if I open that HTML, it seems that all the sources and scripts are dysfunctional, e.g no images, buttons etc are loaded, and no js functions work. So how can I open a HTML using WinSCP so that all the sources are loaded and work properly? Thanks a lot.
I assume you "Open" the HTML file from a remote panel of WinSCP.
This makes WinSCP download the file to a temporary local folder and open the file from there.
As all the references to images and java script files are typically relative paths, they won't work from the temporary folder as the referenced files are not there. So it cannot work.
Either you need to download all files (including images and .js) to a local folder and open the HTML there.
Or you actually want to open the file from the server, via HTTP.
For that use the WinSCP extension "Generate HTTP URL".
Related
I want to write a selenium program on a site which I need as part of the process to browse a file from the operating system. How can I do that?
If you mean to use Selenium to open a html file on local, it's easy to do.
1. open the html file on browser
2. copy the url in browser address, it should be like:
file:///C:/workspace/js-projects/tey/protractor-cucumber-tey/reports/cucumber_report.html
3. put above url in browser.get()
Better way it's to caclcute the html file absolute path in your scritp dynamically (rather than hard code), then prefix with file://// on the path, possible need to replace '\' to '/' in path.
I don't know what you mean by "browse a file from the operating system."
If you mean choosing file to upload, you can.
see link below
https://www.programcreek.com/java-api-examples/index.php?api=org.openqa.selenium.remote.LocalFileDetector
If you want to browse a file in the local machine with the OpenFileDialog (not sure if this is what you are looking for), in my case, I created an autoIt script, building it as .exe and then call it from Java code (or any programming language you are using with Selenium).
I found an exmaple, it might works: https://github.com/ellysh/autoit-examples/blob/master/Helpfile/FileOpenDialog.au3
I am using scrapy to scrape a website and I can download the file from the page, however everything that is being download is a plain text file. How do I download it with it's extension type? I am downloading scripts and as such, having the proper extension type on my download is necessary.
For example, if I am downloading exploits from exploit-db, the link that I go to to download them would be for example: https://www.exploit-db.com/exploits/19832/
and the link i would extract from there to download from is https://www.exploit-db.com/download/19832 which will, if I click on it normally, download a ruby file. But through scrapy it gets saved as a text file. Is there a way to download it as a .rb through scrapy?
Just save it as filename.rb. All files are text/binary files. Extension is there just to tell your operating system what to use to understand that file.
(In some operating systems extension isn't even required since files have headers at the beginning of the file telling what they are)
You can do try this:
scrapy shell https://www.exploit-db.com/download/19832
Then in the shell or your spider just do:
with open('ruby_file.rb', 'wb') as ruby_file:
ruby_file.write(response.body)
I have a very particular case and I don't know if this is possible to be done.
I'm using NWJS to run a web app as a desktop app. I need to zip/package the source files because my code should not be available to eavesdroppers. This package will be delivered on a flash drive. And this is were my trouble begins.
There are a lot of .pdf file that must be shipped together with the package. The user can browse which pdf he wants to open, and when he clicks it, the pdf is "downloaded" to his pc. The content of the pdf is NOT available on the application. I have a list with the name of each pdf file.
If I zip/package the .pdf together with the source files it becomes a huge .nw file and it takes forever for my application to load. I need to mantain the pdf on a separate folder and they need to be accessible through the source code. This is easy if i run the application directly without packaging it, as nw uses the relative url to it's root, but when I do package nw uses a temp folder for the source files and I can't use relative url to access the pdf folder.
The only approach i can think of is to write a js script to identify where the flash drive was mounted but i don't know if this is possible.
I have to support Windows and Mac for this case.
Searching on NWJS google group i found that the answer was quite simple. These two lines returns the path where the nw bin is running. From there is quite simple to get the pdf folder.
var path = require("path");
pathstr = path.dirname(process.execPath);
I’m making a simple web browser for work eeh, what I’d like to know is if its possible to save a file of a particular extension to a particular file.
I currently use google chrome when downloading a file it places this (regardless of extension) in a downloads folder without asking where I ant to download this too.
I want to achieve the same except that downloads with the extension .dwg are placed automatically in a folder named DWG DOWNLOADS…
How to achieve this in vb.net?
In any browser you have a config section.
In Firefox you have browser.download.useDownloadDir;true and browser.download.folderList;1
you can add your own config to allow different saved folder paths and dynamically modify them depending on the extension of the file you uploaded.
See a complete list of the web browser config with about:config in address bar.
Not real sure what you are asking, but if you are actually making a web browser just check the extension of the file you are requesting to download. If the extension is ".dwg" then save the file to the folder you want.
If you are wanting to automatically move Google Chrome downloads to a different directory, you can use a FileSystemWatcher to monitor for new files in Chrome's download directory and move them to another folder based on each file's extension.
I am properly sending a nsurlrequest to download a known path file and then save it to document directory. However, now I need to download all files that a remote directory contains. I know path for directory but not which files are inside. How to list that files in order to build paths to download it? Thank you.
Unfortunately unless you parsed a index file containing a list of the files, this is not possible as the HTTP protocol does not support directory listing. You would have to use an FTP server instead