开发者

How do I use curl to display a table on a page?

开发者 https://www.devze.com 2022-12-24 12:53 出处:网络
I want to use curl to retrieve a table from an external page. So far my code retrieves all data from the page. I have read that using preg_match or preg_replace is the way to go about it.

I want to use curl to retrieve a table from an external page. So far my code retrieves all data from the page. I have read that using preg_match or preg_replace is the way to go about it.

This is my code so far:

<?php
$ch = curl_init() or die(curl_error());
curl_setopt($ch, CURLOPT_URL,"http://www.megaupload.com/?d=XE30L1GA&w=631&h=392");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data1=curl_exec($ch) or die(curl_error());
echo "<font color=black face=verdana size=3>".$data1."</font>";
echo curl_error($ch);
curl_close($ch);
?>

This is the data I want to retrieve from the page:

<FORM method="POST" id="captchaform">

    <INPUT type="hidden" name="captchacode" value="1a589e0a53c54f937eb8">
    <INPUT type="hidden" name="megavar" value="bed55b1a7a26e4bb0aa11df4188f58bda6958d72856a637ca55cbda4c24c89b97d52e39e3a2d1d26082273dec61e68416bd929d566cf63cd8441e9f6166d667618060608c5d63c9341e72fc036ea4ed1ec8d099bc488fa1f3c5df7228e10a0f79c4e5fb78fe41f0d9873194c56f94dfbcc008e4a7c8ebc58c8169d42cb98a9a86d8cb6dfbae8791b9dfcf5a3119f7941cc07e9ba48934ad9b5f865cd32e71bf6d3a3954ddc4e75925aaf2c0ec6d1dd884ccc4d299be3e41957a967e68a143af49d6b7ff7b36dac725f20214e58feb32662e09f5840ac76cff67f7d99e67ffb485d72382dd2开发者_运维问答0cece80e4307dfef720a51734d7f9a4a363de0950d3d0e927423642a79b2e68ed177d2ad2d877c1c2052969ec61737749b05864b3a74d241981d6b89">
    <TR>
        <TD>Enter this </TD>
        <TD width="100" align="center" height="40"><img src="http://wwwq32.megaupload.com/gencap.php?23243f17c2404dd4.gif" border="0" alt=""></TD>
        <TD> here:</TD>
        <TD><input type="text" name="captcha" id="captchafield"  maxlength="4" style="border:solid 1px; border-color:#C4C4C4;  background-color:#F9F9F9; width:50px; height:25px;"></TD>

    </TR>
    </FORM>


preg_*() is certainly not the way to do it. Use a HTML parser.

0

精彩评论

暂无评论...
验证码 换一张
取 消