php - Scripts after doing cURL don't work. Page is reloaded continuously -
these steps want do:
get html code of http://www.skyscanner.es/ , search of flights. get part of html: specific "span" has price. operate it.this php code do:
<?php $ch = curl_init(); curl_setopt($ch, curlopt_url, "http://www.skyscanner.es/"); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt ($ch, curlopt_post, 1); curl_setopt ($ch, curlopt_postfields, "from=bilbao (bio)&to=barcelona (bcn)&depdatetext=25/03/2013&sc_returnoroneway=2"); $output = curl_exec($ch); curl_close($ch); echo $output; ?>
but unusual string this:
‹¥tkoÚ0ý^‰ÿpti“ê< t%<¤rur»u+{}4ñ…x5qf›×pÿûì$zõÛ‚Äu¬sî=çú:ýÓ믣Éï‡1¤f!àáû§»Ï#ðhül‚àzr ¿n'÷wù!<Åã/x©1yëõÚ_·}©æÁä[°qy"g«–dŸæ 'ý¢Êf!2=x#cÔívkb fÊ\\ ¡àÐÿ,ùjàdf03d²Íу¤|x7&pì$)uÍ€ki®®:]yke¸8¼;@àv2y€ª),520h’ Ö`r®!§s3i€ !×Èü~pòm"m¶ÁxuÝdëbô)!“©dÛÝ‚ª9Ïâ°7³‰æ1ö?à¢|ÑÛø*f3z§ânq¬ÐðÄîhši¢qñyoj“§¹’ËŒÅÍqñôž'3Ž‚y“»œ2ƳybÔÉ7…îÏ®zÏÐ8i£Ý¡~Ë¿°ja‰rÅÍ››—/m!£bêkähÚ§ÌÛ~nÐeýÐýö´0¬imw¨¨vkÎlw/ÏêeoæÒ&ia^ôÌ3 §Ë$e÷Þ9Ô=<êØ‘3{uûhµß)gºymÏî…[1—š.³x¡ †¯Ð¡ý m\¤<³fŽÏÆ•{mŒ™Çwö0öÆ\{ÞÎnˆ bµ¿nœ\d|œÙ›sôÐöÓhøˆÊÎ0Œ•’Ê2¢a?°°ct¥Ùm'›‰ z×û/6á~¦úië?®Š%—iÚÃiŠ%h+—@‚òÉöfrab3gœ"0®sa·¶Àj+Í€g+*8ûh%ƒwµ”÷°¦ú Ç\ä¦ÒåÊ·¿aí¨îk÷m-¾vñà-ú¡
so, have not passed first step!
i tried prepare in several ways don't know yet doing wrong. imagine can be:
the request because don't add together how much adult, children... the curlopt_url has www.skyscanner.es/search.html form has in action. not post request, curl straight url http://www.skyscanner.es/flights/bio/bcn/130325/airfares-from-bilbao-to-barcelona-in-march-2013.html?flt=1please can help me?
thanks in advance!
edited: i've changed title, closer problem have now.
it doesn't matter message encoded in body since you're receiving:
http/1.1 405 method not allowed
which means can't utilize post
.
if you'll read headers of response you'll see 1 of them says:
allow: get, head, options, trace
if you'll remove 2 lines:
curl_setopt ($ch, curlopt_post, 1); curl_setopt ($ch, curlopt_postfields, "from=bilbao (bio)&to=barcelona (bcn)");
and change:
curl_setopt($ch, curlopt_url, "http://www.skyscanner.es/");
into:
curl_setopt($ch, curlopt_url, "http://www.skyscanner.es/vuelos/bio/bcn/130325/tarifas-de-bilbao-a-barcelona-en-marzo-2013.html");
it'll work.
checkout next code:
<?php $accept = array( 'type' => array('application/rss+xml', 'application/xml', 'application/rdf+xml', 'text/xml'), 'charset' => array_diff(mb_list_encodings(), array('pass', 'auto', 'wchar', 'byte2be', 'byte2le', 'byte4be', 'byte4le', 'base64', 'uuencode', 'html-entities', 'quoted-printable', '7bit', '8bit')) ); $header = array( 'accept: '.implode(', ', $accept['type']), 'accept-charset: '.implode(', ', $accept['charset']), ); $encoding = null; $ch = curl_init(); curl_setopt($ch, curlopt_url, "http://www.skyscanner.es/vuelos/bio/bcn/130325/tarifas-de-bilbao-a-barcelona-en-marzo-2013.html?flt=1"); curl_setopt($ch, curlopt_returntransfer, 1); // curl_setopt ($ch, curlopt_post, 1); // curl_setopt ($ch, curlopt_postfields, "from=bilbao (bio)&to=barcelona (bcn)"); curl_setopt($ch, curlopt_header, true); curl_setopt($ch, curlopt_httpheader, $header); $response = curl_exec($ch); curl_close($ch); if (!$response) { // error fetching response } else { echo $response; } ?>
php javascript post curl request
No comments:
Post a Comment