douqie1852 2013-05-13 09:52
浏览 46
已采纳

如何以正确的方式使用zend_http_client或curl

I'm using zend_http_client. What i want is to send a request to transfer(without redirecting) to another site and send number in field that I have and get the answer with info i need to use on my site. That's what i'm doing, but how to send my number to that field and submit it?

 $url = 'http://gdeposylka.ru/';
                        $config = array(
                            'timeout' => 30
                        );
                        $client = new Zend_Http_Client($url, $config);
                        try {
                            $response = $client->request('GET');
                            if ($response->getStatus() == 200) {
                                $ctype = $response->getHeader('Content-type');
                                $body = $response->getBody();
                                $dom = new Zend_Dom_Query($body);
                                $results = $dom->query('limit');
                                $item->site_k = 1 + (int) $results->current()->textContent;
                                var_dump($response);
                                exit;
                            }
                        } catch (Zend_Http_Client_Adapter_Exception $e) {

                        }

Thanks and sorry for grammar mistakes.

  • 写回答

1条回答 默认 最新

  • doulao2128 2013-05-13 10:33
    关注

    Because there is a hash on the site you're trying to send a request, you probably wont be able to get this done. Hash mechanism makes it impossible to send request straight to the URL stated in action param of form tag. It's designed particulary to prevent such action you want to make. Still, since there is no captcha you can try web automation.

    What you might find useful is ie. Selenium http://docs.seleniumhq.org/

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

报告相同问题?