Persistent Edit In Chrome DevTools - google-chrome

There's an online tool that I'd like to tweak. It depends upon a JSON file. The easiest way for me to make the changes that I desire is to edit this JSON file directly, which I'm doing using the "Edit text" feature of Chrome DevTools. Next, I need to reload the main webpage so that it fetches the edited JSON file. Of course, this doesn't work because the webpage fetches the resource from the server. Is there any way to make the webpage temporarily load my edited JSON file?

Related

Firefox: view raw JSON on network tab

I'm having a problem with Firefox's debugging panel, spcecifically on the Network tab; when a POST request sends some JSON, it shows the request body inside a tree-like viewer; while this viewer is cute and everything, I actually need to copy and paste the actual raw JSON text into another tool.
There doesn't seem to view the actual JSON request from this panel. Does someone know of some way of viewing the actual RAW JSON inside it?
After some fumbling around, I found out that if you right-click the request, the browser gives you the option to copy the post data (which would return the JSON, if it is a POST) or to "Edit and resend", which would open a dialog that, among other things, has the JSON itself.

Can node-red html be edite elsewhere?

I'm developing a node-red application right now that uses a html response. The html uses google maps, visual indicators and websockets. It is very hard to debug this system through node-red's little html editor. Is there a way to edit the html file through any normal editor (e.g. vs code) and then deploy the application again to see the effect ?
One solution that came to my mind was to read from an external file using the file node and return it as html, put I don't know if that works. Is there a better way ?
You can create and edit static resources (html/css files etc) however you'd like and then serve them from Node-RED.
You have two options for serving static content:
create corresponding HTTP In -> File In -> HTTP Response flows for each file you want to serve
or use the httpStatic property in your settings.js file to identify a directory whose content should be automatically served by the runtime.

How to use a download link to download a file in Python

Basically I am trying to write a script which will grab certain files on a webpage and download it to specific folders.
I am able to complete this with most of the webpages using Python, Selenium, and FirefoxPreferences.
However, when I try to grab off of this specific webpage, due to credential rights, I can't parse the html.
Here is the question. I am able to grab the download link for the file, and I can open a browser and have the open/save widget pop up. I can't however click or actually down the file any further. I have already set the Firefox Preferences to not show this widget, to download automatically, and to a specific file. This is ignored for some reason, and I am still left staring at the open browser, with the save/open widget.
How do I use the download link of a file to download to specific folder using Python... Selenium... any other related CS tricks. I don't want to build a bot to click the save for me. Too "hacky" and this is a company project.
Thanks!
you can try urllib
urllib.urlretrieve(<url>,<filename_with_path>)
import urllib
testfile = urllib.URLopener()
testfile.retrieve("http://randomsite.com/file.gz", "file.gz")
The good way to download a file with python.
Refer Here

save html page from the server by URL with no changes - get the exact copy, the clone

Let's say I have a URL http://example.com/path/to/document.html
That's the html document, the file, that has no external css or js.
If I open it in Google Chrome and save it with Ctrl+S locally, the content is changed. The content of that html file starts with <!-- saved from url= which is not I want at all. I need to get the exact html document, even spaces count.
The second option is to copy it with Ctrl+U (View Source), Select All and paste it into new document, save it and rename it. This is better, however spaces, tabs and end of file will be different depending on what operation system I'm using.
I need the exact copy of that html file - byte to byte.
How to make it?
This is a practical question as I need slightly modify that document.
I'm sorry there is no any source code in my question, but this question is about web developing.
Any ideas?
Thank you.
P.S. Of course that document could be generated by php or whatever, the part of the code can be even extracted from the db, but not in my case. I know that's a plain file.
I'd delete the comment after saving from Chrome, use wget in a linux environment, or open the page as an InputStream in Java. Do all three, run a diff, and if two arrived identical assume that's the file on the server.
Why do you need a byte-for-byte copy of the file on the server anyway, and why can't you ftp the file? There is always the chance that the server will serve different html files depending on your user-agent, but there are other tools which may be better than Chrome for getting your copy and many can spoof a user-agent as well.

How can I determine the real content type of an HTTP response with an incorrect one?

I'm trying to write an extension that corrects 'incorrect' content types. An example situation is a user might click on a link to a PDF file that has the HTTP Content-Type set to application/octet-stream. In this case, I want to be able to detect that the real content type is application/pdf.
A simple but not-so-robust way to do this would be to define my own mappings from file extensions to content types. However, it would be good if I could re-use existing work to do this.
I noticed that Chrome is able to determine how to display files obtained via the ftp and file protocols, which I don't believe provide content type information. How does Chrome do this? Does it inspect the file contents? Does it check the file extensions? Most importantly, can I programmatically hook into this content type detection functionality for my extension?