python - Sensible way to create filenames for files based on URLs? -
i screenshotting bunch of web pages, using python selenium. want save pngs locally reference. list of urls looks this:
www.mysite.com/dir1/pagea www.mysite.com/dir1/pageb my question filenames give screenshotted pngs.
if call image files e.g. www.mysite.com/dir1/pagea.png meaningless slashes inevitably cause problems @ point.
i replace / characters in url _, suspect might cause problems too, e.g. if there _ characters in url. (i don't strictly need able work backwards filename url, wouldn't bad thing.)
what's sensible way handle naming?
the easiest way represent what's directory structure on server wget , replicate structure on local machine.
thus / characters become directory delimiters, , www.mysite.com/dir1/pagea.png become png file called pagea.png in directory called dir1, , dir1 located in directory called www.mysite.com.
it's simple, guaranteed reversible, , doesn't risk ambiguous results.