Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在页面加载后提交帖子字段(cURL\u exec)?_Php_Curl_Html Parsing_Captcha - Fatal编程技术网

Php 在页面加载后提交帖子字段(cURL\u exec)?

Php 在页面加载后提交帖子字段(cURL\u exec)?,php,curl,html-parsing,captcha,Php,Curl,Html Parsing,Captcha,我必须创建一个机器人从我的大学网站收集一些数据,它使用simeple登录和regno和captcha字段,他们不使用真正的captcha,这是一个假的(可以在页面源代码中看到)。所以我的想法是使用DOM解析器并从eg获取它 我是一个使用PHP Curl来做这项工作的人。 我的代码:` <? $ch = curl_init(); $captch = i will get the value from DOM Parser ( But here is the problem , i have

我必须创建一个机器人从我的大学网站收集一些数据,它使用simeple登录和regno和captcha字段,他们不使用真正的captcha,这是一个假的(可以在页面源代码中看到)。所以我的想法是使用DOM解析器并从eg获取它 我是一个使用PHP Curl来做这项工作的人。 我的代码:`

<?
$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);
?>

问题是,一旦我运行curl\u exec,通过解析获取captca,要提交它,我需要再次curl\u exec,这会导致重新加载captcha


有解决办法吗?除了卷发?我准备好使用另一个库了

为什么不使用另一个cURL请求来获取captcha值,然后将其传递到您的post字段中?第一个cURL请求给我一个captcha值,但是无法作为post提交给另一个curl\u exec,因为此新请求的captcha值已更改。我想我必须将PHPQUERRY与curl一起使用。您的浏览器会做什么?登录至少需要2次请求,一次加载表单并获取验证码,然后再次提交表单并传递验证码。使用cURL,您不需要PHPQuery或任何其他库来执行此操作。@drew010:我希望我可以使用cURL来执行此操作,我使用PHPQuery仅用于解析..请查看此图片以获取帮助