예제 #1
0
 /**
  * Parse HTML page for hidden fields in form
  * @param  string $body Html with form
  * @return array        Return array with pair name and value
  * @throws ParserException Throw exception if POST form not found
  */
 public static function getHiddenInputValues(&$body)
 {
     $page_values = [];
     $html = new HtmlDomParser();
     $html = str_get_html($body);
     if ($form = $html->find('form[method=post]', 0)) {
         $inputs = $form->find('input[type=hidden]');
         foreach ($inputs as $input) {
             $page_values[] = ['name' => $input->name, 'value' => $input->value];
         }
     } else {
         throw new ParserException('Page POST form not found');
     }
     Log::debug('------ Parser start ------');
     Arrlog::arr_to_log($page_values);
     Log::debug('------- Parser end -------');
     return $page_values;
 }
예제 #2
0
 /**
  * Bid on yahoo lot with seted price
  * @param  int $price      Price for bid
  * @param  string $auc_url URL with auction ID
  * @return bool            Reurn true if bid successful
  */
 public function bid($price = null, $auc_url = null)
 {
     $body = $this->getBody($auc_url);
     $values = Parser::getHiddenInputValues($body);
     $options = $this->createRequstOptions($values, $price);
     Log::debug('------ Browser start ------');
     Arrlog::arr_to_log($options);
     Log::debug('------- Browser end -------');
     $body = $this->getBody(static::$BID_PREVIEW, null, $options, Requests::POST);
     $values = Parser::getHiddenInputValues($body);
     $options = $this->createRequstOptions($values, $price);
     Log::debug('------ Browser start ------');
     Arrlog::arr_to_log($options);
     Log::debug('------- Browser end -------');
     if (\Config::get('my.test_mode.enabled')) {
         $body = $this->getResultPage();
     } else {
         $body = $this->getBody(static::$PLACE_BID, null, $options, Requests::POST);
     }
     $result = Parser::getResult($body);
     return $result;
 }