I am trying to download the content of this webpage with wget:
https://bibliotheque-numerique.paris.fr/search.aspx?SC=DEFAULT#/Search/(query:(ForceSearch:!f,Page:0,PageRange:3,QueryString:'*:*',ResultSize:50,ScenarioCode:DEFAULT,ScenarioDisplayMode:display-standard,SearchLabel:'',SearchTerms:'',SortField:DateOfInsertion_sort,SortOrder:0,TemplateParams:(Scenario:'',Scope:VPCO,Size:!n,Source:'',Support:'')))
It doesn't work because of the special characters. I have tried to escape them with "\", but it doesn't work for me.
Since the search query only uses single quotes, you can use double quotes to protect them from the shell. In addition, in zsh (and possibly other interactive shells) you need to escape the ! character with a backslash, since ! has meaning even inside double quotes. The result looks like this:
# use double quotes and escape "!"
wget "https://bibliotheque-numerique.paris.fr/search.aspx?SC=DEFAULT#/Search/(query:(ForceSearch:\!f,Page:0,PageRange:3,QueryString:':',ResultSize:50,ScenarioCode:DEFAULT,ScenarioDisplayMode:display-standard,SearchLabel:'',SearchTerms:'',SortField:DateOfInsertion_sort,SortOrder:0,TemplateParams:(Scenario:'',Scope:VPCO,Size:\!n,Source:'',Support:'')))"
To avoid such problems, you can use wget -i to specify an input file, where the URLs will be read line by line without interpretation of special characters (except for the newline character, which separates the lines). In conjunction with the << operator, it allows specifying the URL without special quoting:
# use -i - to read from stdin, and the <<\ operator to feed
# the URL to Wget without having to quote it
wget -i - <<\.
https://bibliotheque-numerique.paris.fr/search.aspx?SC=DEFAULT#/Search/(query:(ForceSearch:!f,Page:0,PageRange:3,QueryString:':',ResultSize:50,ScenarioCode:DEFAULT,ScenarioDisplayMode:display-standard,SearchLabel:'',SearchTerms:'',SortField:DateOfInsertion_sort,SortOrder:0,TemplateParams:(Scenario:'',Scope:VPCO,Size:!n,Source:'',Support:'')))
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With