views:

1166

answers:

1

I keep getting a 400 bad request code from a hotfile.com page when I try to get it with curl.

  1. I can get the pages fine in the browser
  2. The first (login) (post) request in the script works
  3. The last (get) request in the for loop works
  4. I have tried setting the curl headers to the same headers sent by my browser
  5. I have tried sleeping up to 5 seconds between requests, to no difference

The problem is all the curl get requests in the for loop return a 400 bad request except for the last one which is freakin weird to me.

Here's the link to the script: http://pastie.org/627436 I am using Sean Hubers curl wrapper: http://github.com/shuber/curl And also SimpleHMTLDOM: http://simplehtmldom.sourceforge.net/

It might be difficult for people to try unless you have a hotfile account as the script won't work on a non-registered account.

Cheers in advance :)

+3  A: 

my first guess would be changing

$urls = explode("\n",$_POST['urls']);   => $urls = explode("\r\n",$_POST['urls']);

(\n => \r\n)

since you said the last one is working, I would imagine URLs prior to the last one are http:\xyz.com\r as a result of this explode. Basically make sure your URL list after explode contains no extra chars, perhaps even call a trim on it. Just a guess though since I can't test it without an account :)

Mohammad
Thank you very very much this worked perfectly, must have been a funny character, trim sorted it out. THANK YOU!! :) :)
hamstar