I'm writing a Crawler in Python and I'm trying to save the html
of the crawled pages in a file with the name of the urls. However, the urls have slashes in it, which is probably the reason why my code below is not working.
path = "directory/subdirectory"
url = "http://stackoverflow.com/"
file_path = path + "/" + url
tmp = open(file_path, 'a')
tmp.write(html)
tmp.close()
How can I create a file with /
in its name?
Please, consider that the directory/subdirectory
already exists.
Update:
As our friend @jorgeh
mentioned, we can convert the /
to ASCII code. So, even though this question might be a duplicate, it has a different solution.