开发者

Wget recognizes some part of my URL address as a syntax error

开发者 https://www.devze.com 2023-02-23 12:22 出处:网络
I am quite new with wget and I have done my research on Google but I found no clue. I need to save a single HTML file of a webpage:

I am quite new with wget and I have done my research on Google but I found no clue.

I need to save a single HTML file of a webpage:

wget yahoo.com -O test.html

and it works, but, when I try to be more specific:

wget http://search.yahoo.com/404handler?src=search&p=food+delicious -O test.html

here comes the problem, wget recognizes &p=food+delicious as a syntax, it says: 'p' is not recognized as an internal or external command

How can开发者_StackOverflow中文版 I solve this problem? I really appreciate your suggestions.


The & has a special meaning in the shell. Escape it with \ or put the url in quotes to avoid this problem.

wget http://search.yahoo.com/404handler?src=search\&p=food+delicious -O test.html

or

wget "http://search.yahoo.com/404handler?src=search&p=food+delicious" -O test.html

In many Unix shells, putting an & after a command causes it to be executed in the background.


Wrap your URL in single quotes to avoid this issue.

i.e.

wget 'http://search.yahoo.com/404handler?src=search&p=food+delicious' -O test.html


if you are using a jubyter notebook, maybe check if you have downloaded

pip install wget 

before warping from URL

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号