2013-05-13 78 views
0

我正在使用zend_http_client。我想要的是发送一个请求(无重定向)到另一个站点,并发送在我的字段中的数字,并获得我需要在我的网站上使用的信息的答案。这就是我所做的,但如何将我的号码发送到该字段并提交?如何使用zend_http_client或正确卷曲

$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) { 

         } 

感谢和遗憾的语法错误。

回答

1

因为网站上有一个哈希值,所以您可能无法完成此操作。散列机制使得不可能直接向action参数form标签中所述的URL发送请求。它的目的是为了防止你想要做的这种行动。尽管如此,由于没有验证码,你可以尝试网页自动化。

你可能会发现有用的是ie。硒http://docs.seleniumhq.org/

+0

感谢您的帮助 – Stopper 2013-05-13 10:50:49

+0

这个网站怎么样http://www.track-trace.com/post或http://www.emspost.ru/ru/corp_clients/dogovor_docements/api/ – Stopper 2013-05-13 11:03:26

+1

我看不懂cyryllic但在第二个网站上我看到有一些API,这应该是非常有用的。你可以用'file_get_contents('http://emspost.ru/api/rest?method=ems.test.echo')'很容易地得到JSON'(注意,这个函数可能会在你的服务器上用'allow_url_fopen'标志关闭)。 – Wiktor 2013-05-13 11:12:33