When download big files, I usually do it from code with HTTP "Range requests" requests.get('http://example.com/bigfile.zip', header={"Range": "bytes=1000000000-2000000000"}) when I need to download starting at offset 1 GB, for example if the first GB has already been downloaded but the download has been interrupted.
But in some cases, we need to be authenticated (using a login page that doesn't work outside of a real browser) to be allowed to download the file http://example.com/bigfile.zip.
Question: let's say I did the login in Firefox or Chrome. How to trigger a HTTP Range Request to download http://example.com/bigfile.zip from browser, starting at offset 1 GB?
Preferably, I'd like to do this directly from Chrome or Firefox, using DevTools or Javascript console, and without an extension, if possible.
Related
I want to access live XHR request data in Chrome programatically. (I can't just connect to the website using a script, it must go through Chrome)
So far, I've found the easiest way to do this is to launch Chrome with remote-debugging turned on. And then use Chrome DevTools to get the data:
import PyChromeDevTools
chrome = PyChromeDevTools.ChromeInterface()
chrome.Network.enable()
chrome.Page.enable()
chrome.Page.navigate(url='http://example.com/')
The Chrome DevTools protocol guide is here:
https://chromedevtools.github.io/devtools-protocol/
But I don't know how to actually access the live XHR requests.
Here's the data shown in the Chrome DevTools UI:
The connect requests contain everything I need in the response body. I simply need access to them live (as they continue to stream in).
I just want to access this data using DevTools-protocol so I can further process it.
Any ideas how?
I wrote a webapp that I use to store various information locally using Local Storage in Firefox. I want to run the webapp in Chrome or another brower using the same local storage data. Is that possible? If not, is it possible to copy the local storage data created by the webapp in Firefox to a file that can be used by the same webapp in Chrome?
localStorage is a storage on client side(web browser), you can't share localStorage of one browser with other.
Although you can copy localStorage content by running given javascript in browser console
copy(JSON.stringify(localStorage));
it'll copy all localStorage content to clipboard.
Now, you can import it into another browser by running given javascript in console
var data = '/*paste stringified JSON from clipboard*/';
Object.keys(data).forEach(function (k) {
localStorage.setItem(k, data[k]);
});
I am writing a chrome app which needs to download videos from urls in background after specific time intervals.
Unlike chrome extension ( which has chrome.downloads api to deal with downloads ) chrome.downloads in not available for chrome apps.
If I use filesystem api, it shows the save location dialogue which I do not want. As, I need downloads to be dealt in the backgorund.
Is there any work around for this requirement ?
I tried using very simple HTML to create several links to several batch files on my server that are intended to run when users click on the links. Using Chrome, every time I click on one of those files my browser displays the script itself (even though its a .bat) and doesn't actually run the script. Internet Explorer runs it every time, however all the users on the network use Chrome for web browsing.
Is there any way to force Chrome (preferably through HTML or VB or some other scripting on the page itself rather than change all of the users' browser settings) to run these batch files when the user clicks on the link?
The answers given so far - that it's "not possible" - are incorrect or outdated. Using Chrome Apps you can call executables (called "hosts") if they are registered with Chrome. Of course a Chrome App is a client application so you need to distribute it.
See https://developer.chrome.com/extensions/nativeMessaging#examples
HTML, JS on browser cannot run shell command, command line. You have to implement server script to execute your bat file then call it from HTML, JS via Ajax or direct link.
At the moment I am developing a Google Chrome Extension in which I have to fetch data from a server. I am doing this with an XMLHttpRequest and all is going well, except for the fact when I launch Google Chrome and immediately click my extension, it won't open until the XMLHttpRequest is completed. The request is sent to a rather slow server, that's where the problem is. But is there a way in which you might run the XMLHttpRequest in another thread or does Google Chrome give you another way to fetch data from a server that runs in the background so I can open my extension while it's still getting it's data from the server?
Maybe good to know, the XMLHttpRequest runs in the background page, not the popup page.
Looks like the Asynchronous parameter has to be set to true.