cURL Submitting POST fields after page load ( curl_exec )?

匆匆过客 提交于 2019-12-25 05:03:08

问题


I have to create a bot to collect some data from my college website , it uses simeple login with regno and captcha fields , they dont use real captcha , its a fake one ( can be seen in page source ) . So my idea is to use a DOM Parser and fetch it from eg

Im a using PHP-Curl to do this job . My Code:`

<?
$ch = curl_init();
$captch = i will get the value from DOM Parser ( But here is the problem , i have to get it before even executing the page !! ) 
$fields = "regno=11BTA00&captcha=$captcha";
curl_setopt($ch,CURLOPT_URL,$loginurl);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields);
$data = curl_exec($ch);
curl_close($ch);
?>

The Problems is once i run curl_exec , get captca by parsing , to submit it i need to curl_exec again which leads to reloading of captcha ..

Any workaround for this ? other than cURL ? Im ready to use another library

来源:https://stackoverflow.com/questions/10926604/curl-submitting-post-fields-after-page-load-curl-exec

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!