1) Look at the functions in calibre.ptempfile
2) That's what webkit does.
3) P simply resolves relative paths to files in the resources folder of your calibre install to absolute paths (look at calibre.utils.resources)
Notice to all: I can not
provide assistance with DRM removal, for legal reasons, so please do not contact me about it.