dongmaopiao0901 2009-09-23 15:19
浏览 1006
已采纳

使用PHP Curl获取页面时出现400 Bad Request

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 :)

  • 写回答

1条回答 默认 最新

  • douzhu3367 2009-09-23 17:36
    关注

    my first guess would be changing

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

    since you said the last one is working, I would imagine URLs prior to the last one are http:\xyz.com 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 :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题
  • ¥20 Oracle替换.dbf文件后无法连接,如何解决?(相关搜索:数据库|死循环)
  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号
  • ¥15 算法使用了tf-idf,用手肘图确定k值确定不了,第四轮廓系数又太小才有0.006088746097507285,如何解决?(相关搜索:数据处理)
  • ¥15 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)
  • ¥15 如何解决MIPS计算是否溢出
  • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理