I'm trying to implement some code that downloads files from some webpages.
I am using the built-in functions Import
and StringReplace
.
I found that when I import a url that contain blanks I need to replace them with %20, however in some strings "\" appears suddenly.
For example,
StringReplace[http://ww.aaa.com/asd/dfh asda asd.pdf, " " -> "%20"]
I expect this to give "http://www.aaa.com/asd/dfh%20asda%20asd.pdf".
Using this string with FetchURL
, I try to download the file but it does not work.
I found that when I copy the same string and paste it somewhere, it looks like:
I suspect that the "\" is causing the problem. What's the proper way to deal with "\" characters here?
URLEncode["yourstring"]
(docs here) that will take care of all the URL encoding for you. $\endgroup$