Jump to content

Mix1988

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Mix1988

  1. This is really awesome and suits me best, thank you very much!!!
  2. Ok i see, so this isnt a good method afterall for geting data from html table, what should i use? As far as googleing goes everybody seems to like SimpleHtlmDom parser, but i had 0 sucess with it...
  3. Hi, how could i extract table data from html? I tried simpleHTMLdom parses with no luck, then i found out that easyer method but its not working for me: <?php $data = file_get_contents('demo.htm'); $dom = new domDocument; @$dom->loadHTML($data); $dom->preserveWhiteSpace = false; $tables = $dom->getElementsByTagName('table'); $rows = $tables->item(1)->getElementsByTagName('tr'); foreach ($rows as $row) { $cols = $row->getElementsByTagName('td'); //echo $cols[2]; print_r($cols); } ?> I get DOMNodeList Object ( [length] => 0 ) like theres nothing. Html table is like this: <table cellpadding="0px" cellspacing="0px" style="table-layout:fixed" ;=""> <tbody><tr> <td width="20" style="min-width:20px;max-width:20px;"></td> <td width="100" style="min-width:100px;max-width:100px;"></td> <td width="150" style="min-width:150px;max-width:150px;"></td> <td width="400" style="min-width:400px;max-width:400px;"></td> <td width="200" style="min-width:200px;max-width:200px;"></td> </tr> <tr> <td rowspan="5"></td> <td rowspan="5" valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;"><b>Aeg</b><br>15.12.2010</td> <td rowspan="5" valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;"><b>Koht</b><br>Harjumaa</td> <td valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;"><b>Sõiduk:</b> BMW 525TDS, 1997</td> <td valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;"><b>Vastutuse ulatus:</b> 0%</td> </tr> <tr> <td colspan="2" valign="top" ,="" style="padding-left:3px;padding-bottom:4px;"><b>Makstud sõidukikahju hüvitis:</b> kuni 500 eurot</td> </tr> <tr> <td valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;"><b>Sõiduk:</b> OPEL ASTRA STATION WAGON, 2006</td> <td valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;"><b>Vastutuse ulatus:</b> 100%</td> </tr> <tr> <td colspan="2" valign="top" ,="" style="padding-left:3px;padding-bottom:4px;"><b>Makstud sõidukikahju hüvitis:</b> sõidukikahju ei hüvitatud</td> </tr> <tr> <td colspan="2" valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;"><b>Käsitlev kindlustusandja:</b> QBE Insurance (Europe) Limited Eesti filiaal</td> </tr> <tr> <td rowspan="5"></td> <td rowspan="5" valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;background-color:#F5F5D1;"><b>Aeg</b><br>28.08.2010</td> <td rowspan="5" valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;background-color:#F5F5D1;"><b>Koht</b><br>Tartu, Tartumaa</td> <td valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;background-color:#F5F5D1;"><b>Sõiduk:</b> AUDI A4, 1996</td> <td valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;background-color:#F5F5D1;"><b>Vastutuse ulatus:</b> 0%</td> </tr> <tr> <td colspan="2" valign="top" ,="" style="padding-left:3px;padding-bottom:4px;background-color:#F5F5D1;"><b>Makstud sõidukikahju hüvitis:</b> 500 kuni 2000 eurot</td> </tr> <tr> <td valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;background-color:#F5F5D1;"><b>Sõiduk:</b> BMW 525TDS, 1997</td> <td valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;background-color:#F5F5D1;"><b>Vastutuse ulatus:</b> 100%</td> </tr> <tr> <td colspan="2" valign="top" ,="" style="padding-left:3px;padding-bottom:4px;background-color:#F5F5D1;"><b>Makstud sõidukikahju hüvitis:</b> sõidukikahju ei hüvitatud</td> </tr> <tr> <td colspan="2" valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;background-color:#F5F5D1;"><b>Käsitlev kindlustusandja:</b> If P&C Insurance AS</td> </tr> <tr> <td></td> <td colspan="4" valign="top" ,="" style="padding-left:3px;padding-top:4px;padding-bottom:4px;border-top-style:solid;border-width:1px;border-color=#4F4F4F;"> </td> </tr> </tbody></table> How could i parse this table best way?
  4. Hey, been messing with one simple thing for hours What is wrong with my code? Idea is to check if string length equals 17 before mysql query. This is not full code, but the problem is here i am sure, it just loads blank page. <?php } if(isset($_POST['textfield']) && (strlen($_POST['textfield'])= 17)){ $uusvin = $_POST['textfield']; mysql_query("UPDATE autod SET vin = $uusvin WHERE number = '$a'"); header("Location: infotest.php?search=$a"); Exit; }else{ echo "length is wrong"; die(); } ?> It just loads blank page
  5. It doesnt work even without slash. <?php $url3 = "https://vs.lkf.ee/pls/xlk/!sysadm.ic_vehicle_history_pkt.show_form"; $data2 = array('p_vin' => 'WBADF81050BT08604','p_key' => 'c0kveql7gz8cr18w2pn23dtzyv33zth6', 'p_request' => ' Otsi ' ); $ch3 = curl_init(); curl_setopt($ch3, CURLOPT_URL,$url3); curl_setopt($ch3, CURLOPT_FAILonerror, 1); curl_setopt($ch3, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch3, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch3, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch3, CURLOPT_SSLVERSION, 3); curl_setopt($ch3, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch3, CURLOPT_POST, 1); curl_setopt($ch3, CURLOPT_POSTFIELDS, $data2); curl_setopt($ch3, CURLOPT_COOKIESESSION, true); curl_setopt($ch3, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($ch3, CURLOPT_COOKIEFILE, "cookies.txt"); $result4 = curl_exec($ch3); if ($result4 === FALSE) { echo ("ERROR: " . curl_error($ch3)); } print_r($result4); ?> I figured out, that this "p_key" thingie is most important for getting results from page. If i leave p_key empty, it tells me session id NULL, How is this p_key generated? And how could i immitate it with curl ? I still think it is related with cookies somehow? Site html is as follows <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" NAME="p_name" CONTENT="text/html; charset=windows-1257"> <TITLE>Sõiduki liikluskahjude kontroll</TITLE> <LINK REL="StyleSheet" HREF="[url="https://vs.lkf.ee/pls/xlk/WEBVIEW.IES_STYLESHEET.style?pstyle=LKF20030522"]WEBVIEW.IES_STYLESHEET.style?pstyle=LKF20030522[/url]" TYPE="text/css"> </HEAD> <div id="header-div"> <A HREF="[url="http://www.lkf.ee/"]http://www.lkf.ee[/url]"><IMG SRC="[url="https://vs.lkf.ee/images/eksl_logo_rgb_v.png"]/images/eksl_logo_rgb_v.png[/url]" ALT="LKF" id="header-logo-eksl", border="0"></A> </div> <div style="margin-left:20px;margin-top:15px;margin-bottom:15px;"> <TABLE > <TR> <TD width= "422.5" style="min-width:422.5;max-width:422.5;"><font id="header-text">Sõiduki liikluskahjude kontroll</font></TD> <TD ALIGN="right" width= "422.5" style="min-width:422.5;max-width:422.5;"><A HREF="[url="http://www.lkf.ee/"]http://www.lkf.ee[/url]" style="color:#1459C0;font-size:11px;text-decoration:none">Avaleht</A> <span style="background-color:#D7D847;"> </span> <A HREF="[url="http://www.lkf.ee/index.php?option=com_content&view=article&id=294&Itemid=210&lang=et"]http://www.lkf.ee/index.php?option=com_content&view=article&id=294&Itemid=210&lang=et[/url]" style="color:#1459C0;font-size:11px;text-decoration:none">Avalikud päringud</A> <span style="background-color:#D7D847;"> </span> <A HREF="[url="https://vs.lkf.ee/pls/xlk/!sysadm.ic_vehicle_history_pkt.show_form"]!sysadm.ic_vehicle_history_pkt.show_form[/url]" style="color:#1459C0;font-size:11px;text-decoration:none">Sõiduki liikluskahjude kontroll</A></TD> </TR> </TABLE> </div> <div id="body-div"> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-36263773-1']); _gaq.push(['_setDomainName', 'lkf.ee']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> <TABLE cellpadding="6px" cellspacing="0px" border="0px" style="table-layout:fixed;"> <TR class="resultHeaderRow"> <TH width="870" valign="middle" align="left" style="padding-left:20px;min-width:845px;max-width:845px;">Päringu sisend</TH> </TR> </TABLE> <FORM ACTION="!sysadm.ic_vehicle_history_pkt.show_form" METHOD="POST" name="p_frm" id="p_frm"> <INPUT TYPE="hidden" NAME="aacxooqa7niv" VALUE="359933"><script>document.p_frm.aacxooqa7niv.value = 273553 + 137394;</script> <INPUT TYPE="hidden" NAME="p_key" VALUE="3vgqv75602eh8kusfl8yvaks9jrj9gne"> <INPUT TYPE="hidden" NAME="poulibijh5vfle6zlf32c" VALUE="415024"><script>document.p_frm.poulibijh5vfle6zlf32c.value = 954316 + parseInt(document.p_frm.aacxooqa7niv.value);</script> <TABLE cellpadding="0px" cellspacing="0px" style="table-layout:fixed";> <TR> <TD width="20" style="min-width:20px;max-width:20px;"></TD> <TD width="250" style="min-width:250px;max-width:250px;"></TD> <TD width="600" style="min-width:600px;max-width:600px;"></TD> </TR> <TR> <TD valign="top", style="padding-left:3px;padding-top:6px;padding-bottom:3px;"><script>var sgfnqpy1ewy1y = parseInt(document.p_frm.poulibijh5vfle6zlf32c.value) + parseInt(document.p_frm.poulibijh5vfle6zlf32c.value);</script></TD> <TD valign="top", style="padding-left:3px;padding-top:6px;padding-bottom:3px;">Sõiduki tehasetähis</TD> <TD valign="top", style="padding-left:3px;padding-top:6px;padding-bottom:3px;"><INPUT TYPE="text" NAME="p_vin" SIZE="25" MAXLENGTH="25" id="p_vin"></TD> </TR> <TR> <TD valign="top", style="padding-left:3px;padding-top:3px;padding-bottom:6px;"></TD> <TD valign="top", style="padding-left:3px;padding-top:3px;padding-bottom:6px;"><script>upnm5kflvjh2zlndwkh8 = 335414;</script></TD> <TD valign="top", style="padding-left:3px;padding-top:3px;padding-bottom:6px;"><script>tgmd197lmn3hovcy9la76x6 = 28574;</script><INPUT TYPE="submit" NAME="p_request" VALUE=" Otsi " id="p_request"></TD> </TR> </TABLE> </FORM> <TABLE cellpadding="6px" cellspacing="0px" border="0px" style="table-layout:fixed;"> <TR class="resultHeaderRow"> <TH width="870" valign="middle" align="left" style="padding-left:20px;min-width:845px;max-width:845px;">Teadmiseks</TH> </TR> <TR> <TD COLSPAN="4" width="870" style="word-wrap:break-word;padding-left:20px;min-width:845px;max-width:845px;">Sõiduki liikluskahjude kontrolli päringu tulemus näitab sõiduki osalemist liikluskindlustuse kindlustusjuhtumis. Samuti teavet sõiduki hävinenuks tunnistamise kohta liikluskindlustuse või muu kindlustusjuhtumi tõttu.</TD> </TR> <TR> <TD COLSPAN="4" width="870" style="word-wrap:break-word;padding-left:20px;min-width:845px;max-width:845px;">Andmete otsing toimub liikluskindlustuse registrist ja kindlustusandja poolt hävinuks tunnistatud sõidukite registrist. Neis registrites on teave kindlustusjuhtumite kohta, mida on käsitlenud Eestis tegutsev kindlustusandja. Päringu tulemus ei näita sõidukiga välismaal toimunut ega juhtumeid, millest kindlustusandjat ei ole teavitatud.</TD> </TR> <TR> <TD COLSPAN="4" width="870" style="word-wrap:break-word;padding-left:20px;min-width:845px;max-width:845px;">Näiteks ei sisalda päringu tulemus: a) sõidukiga välismaal toimunud juhtumeid, B) Eestis toimunud sõidukikindlustuse juhtumeid, kui sõiduk ei hävinud ja kahjustada sai vaid kindlustatud sõiduk, c) teavet liiklusõnnetuste kohta, kus kahjustada sai üksnes üks sõiduk.</TD> </TR> <TR> <TD COLSPAN="4" width="870" style="word-wrap:break-word;padding-left:20px;min-width:845px;max-width:845px;">Avaldatavad andmed on informatiivse iseloomuga ega ole mõeldud kasutamiseks muuks otstarbeks. Registrisse esitavad andmeid kindlustusandjad, mistõttu puudub Eesti Liikluskindlustuse Fondil võimalus ja kohustus nende õigsust kontrollida. Eesti Liikluskindlustuse Fond ei vastuta andmete ebaõigsusest tekkinud kahju eest ega andmete alusel vastu võetud otsuste, tegemata jäänud tehingute ja tehtud tehingute tagajärgede eest. Eesti Liikluskindlustuse Fond võtab tarvitusele kõik mõistlikult oodatavad meetmed tagamaks andmete korrektse ning adekvaatse avaldamise.</TD> </TR> </TABLE> </div> <BR> </HTML>
  6. Thanks, i forgot about hidden field, ok now i got a bit further. Now it displays me captcha, thing is, when i got to this site with my browser there is no captcha nessecery to submit the form, so i guess it still has something to do with cookies. By the way cURL is still not saving any cookies from site.
  7. Hello, i have managed to use cURL many times with different sites, but now i have problem, i think it is cookie related. Site wants session id to display data, my code is as follows: $url3 = "https://vs.lkf.ee/pls/xlk/!sysadm.ic_vehicle_history_pkt.show_form"; $html3 = new simple_html_dom(); $data2 = array('p_vin' => 'WBADF81050BT08604', 'p_request' => ' Otsi ' ); $ch3 = curl_init(); curl_setopt($ch3, CURLOPT_URL,$url3); curl_setopt($ch3, CURLOPT_FAILonerror, 1); curl_setopt($ch3, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch3, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch3, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch3, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch3, CURLOPT_SSLVERSION, 3); curl_setopt($ch3, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch3, CURLOPT_POST, 1); curl_setopt($ch3, CURLOPT_POSTFIELDS, $data2); curl_setopt($ch3, CURLOPT_COOKIESESSION, true); curl_setopt($ch3, CURLOPT_COOKIEJAR, "/cookies.txt"); curl_setopt($ch3, CURLOPT_COOKIEFILE, "/cookies.txt"); $result4 = curl_exec($ch3); if ($result4 === FALSE) { echo ("ERROR: " . curl_error($ch3)); } print_r($result4); So, it prints me site header, some links and then "Session broken (SESSION_ERROR_NULL_KEY)" I think this can be resolved with cookies, but it is not saving any cookies to cookies.txt, i have write permissions on file and everything, but no luck. Maybe problem is elswhere, any help will be appreaciated! Site html is here: http://pastebin.com/PiEGGAUp it has lot of javascript in it that does not make any sense for me .
  8. Ok i finally got it so far, that it loads me the page, but it loads it as no post function is made. Code is as follows, unchanged. <?php $url = "http://195.80.106.137:9050/soidukiPiirang"; $a = "217thd"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_FAILonerror, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'form1=' . urlencode($a)); $result = curl_exec($ch); curl_close($ch); echo $result; ?> I am not sure if curl does not post data from variable $a to form1, or target site makes it hard to get info from there somehow... If i insert value by browser, then site loads info fine. Mix
  9. Hello, i am pretty new to php, and need a little help. I want to submit a value to external site. This external site has a form called "form1" and button called "button1" , form method is post. I have googled for hours and now know that i must use cURL, this is what i have managed to do so far: <HTML> <?php $url = "http://example.com/page2"; $a = "blabla"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_FAILonerror, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, 'form1=' . urlencode($a)); $result = curl_exec($ch); curl_close($ch); echo $result; ?> </HTML> This code gives me no erros, nothing at all only loads blank page, any advice what i am doing wrong? Best Regards Mix
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.