caxpeyr
caxpeyr

Reputation: 284

Curl and wget: why isn't the GET parameter used?

I am trying to fetch data from this page using wget and curl in PHP. As you can see by using your browser, the default result is 20 items but by setting the GET parameter iip to number x, I can fetch x items, i.e. http:// www.example.com/ foo ?a=26033&b=100

The problem is that the iip parameter only works in browsers. If I try to fetch the last link using wget or curl, only 20 items are returned. Why? Try this at the command-line:

curl -O http://www.example.com/foo?a=26033&iip=b
wget http://www.example.com/foo?a=26033&iip=b

Why can't I use the GET parameter iip?

Upvotes: 17

Views: 14337

Answers (4)

Xavier Barbosa
Xavier Barbosa

Reputation: 3947

& is a reserved word in shell. Just escape it like this \&

Upvotes: 3

Romain
Romain

Reputation: 12819

You'll have to enclose your URL in either " or ', since the & has a special meaning in shellscript... That'll give you:

curl -O "http://www.objektvision.se/annonsorer?ai=26033&iip=100"
wget "http://www.objektvision.se/annonsorer?ai=26033&iip=100"

Upvotes: 3

Joey
Joey

Reputation: 354536

Try quoting the argument. At least in cmd, & is used to delimit two commands that are run individually.

Upvotes: 3

Gilean
Gilean

Reputation: 14748

Try adding quotes:

curl -O 'http://www.objektvision.se/annonsorer?ai=26033&iip=100'
wget 'http://www.objektvision.se/annonsorer?ai=26033&iip=100'

The & has special functionality on the command line which is likely causing the issues.

Upvotes: 34

Related Questions