我想从ASP表单中获取价值,但我的所有尝试都失败了。 这是网站上的表格:https://www.dovera.sk/overenia/dlznici/zoznam-dlznikov
例如,我尝试使用此值36471224并在此网站上形成返回值。我正在尝试获取CURL请求,但我还没有成功。它是否可能(我绝望)?如果至少有人以正确的方式驾驶我,我将非常高兴。抱歉愚蠢的问题。
答案 0 :(得分:1)
您可以使用Google开发者工具获取卷曲请求
假设变量没有变化和影响,你可以参考上面的解决方案
<强>解决方案:强>
<?php
function fetch_value($str, $find_start = '', $find_end = '')
{
if ($find_start == '')
{
return '';
}
$start = strpos($str, $find_start);
if ($start === false)
{
return '';
}
$length = strlen($find_start);
$substr = substr($str, $start + $length);
if ($find_end == '')
{
return $substr;
}
$end = strpos($substr, $find_end);
if ($end === false)
{
return $substr;
}
return substr($substr, 0, $end);
}
$post_page = "https://ep.dovera.sk/PublicZone/Neplatici/NeplaticiWeb.aspx";
$search_term = "36471224";
$ch = curl_init();
curl_setopt($ch, CURLOPT_REFERER, $post_page);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7)');
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
$post_string = 'ctl00%24Main%24GlobalScriptManager=ctl00%24Main%24PageUpdatePanel%7Cctl00%24Main%24btnSearch&__EVENTTARGET=ctl00%24Main%24btnSearch&__EVENTARGUMENT=&__VIEWSTATE=DNsB8hM9wz%2FW6xBtn%2FZkhbF6O476J2gngpFKhZ69zbFcSWgUS1mBE0yhm%2BN2G2rYrkyri%2FJdB5zLpoULSuhZCa7%2FJLp6gFVRLeIddMXOUbjS5vvl8sLtVZLZRWA4f8xPTP%2BvklzJvMk1AHGEPuWTL5CkWIzK4j4iNMEWiAw36Dikxs9fW7U7tkbrAwKLwnd%2BRNbaYUV%2FXG74uKswnRCcp6UChwpQb%2FruBXB4F3O1i04y3wLn1je0SS%2BW6NqRtuPUog3eHChPM%2FzrRW9Uap8qHIBKbKWvUZZalTYQBImPMLo7MMn2e5MyeJlBHBvs27mgM3l0%2F9upFZXTYz0Qf6P0WwDsn8zGQgvUgsyU82%2BxOO4o9KPx0CoDj4970zOBTnTY%2B4M8LrYhkaRSAPe0iUFbVbN8YaaIaL55XDgSvC%2FCI22Jqu%2FmGWGi9JVDV11nKJavwGmZDqEk2npf2cuu99sjex0%2B8hXeUSzPNKhpyVgJcNs6dGM%2Bas0ezeVcc8fmue1jiwhVBM6mKaapdOBSI%2FXOjIj%2FCvP3cC9%2FR4J%2FBpqxwPk%3D&__VIEWSTATEGENERATOR=BD62B0C4&__VIEWSTATEENCRYPTED=&__EVENTVALIDATION=cJqi2bjVZY21%2FUyBXt2IDjfqX7O%2B7rlSpeoBTVDLlEo2NS0H7I6q55OoYLV0mgze9JUnEv4x9YlnWxxe5F%2BmR4NAd%2FrohDoYiaOFlVboUhIeJhFIACbORPQRemXeo9CwTQRCEPZ5ZKcixnFvdfFORoNB744G5BEsHON1MyGvF1sic5O2W6RYSxRfM2yslzXrwcBUPsT2mryIEHinE7awsBjCnFJIV%2BfknQq0zVjeHS0BobfJolodHqPkcXDVgurT&ctl00%24Main%24hdLinkNewWindow=&ctl00%24Main%24hdLinkTarget=&ctl00%24Main%24hdXVal=0&ctl00%24Main%24txtSearch='.$search_term.'&ctl00%24Main%24hdwatermark=Zadajte%20meno%20a%20priezvisko%2C%20rodn%C3%A9%20%C4%8D%C3%ADslo%2C%20obchodn%C3%BD%20n%C3%A1zov%20alebo%20I%C4%8CO&recaptcha_challenge_field=03AJIzXZ6kCvOklH6XGTrILEvfL1K6CWph19yWrUyh2B9QdBxFh9LJJ-mN4K2KwUGpDBKN6UCBJ9VuFguJEtMYoB8_2ZjQWnunD3wH_LLuojbCzbzJ1RRyJiq58zbfynXLaKJbAlUcoarElCRfN7VC9xv1V8rfWZCPoiCa2YVDi6ZPqJ2KCDFp6PHXQO96nR-0-7XSS5Y329sX&recaptcha_response_field=&__ASYNCPOST=true&';
curl_setopt($ch, CURLOPT_URL, $post_page);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
$content = curl_exec($ch);
curl_close($ch);
$name = fetch_value($content, '<span id="Main_gwNeplatici_lblNazov_0">', '</span>');
$address = fetch_value($content, '<span id="Main_gwNeplatici_lblAdresa_0">', '</span>');
$ico = fetch_value($content, '<span id="Main_gwNeplatici_lblICO_0">', '</span>');
$amount = fetch_value($content, '<span id="Main_gwNeplatici_lblSuma_0" style="font-weight:bold;">', '</span>');
echo 'Name : '.$name.'<br>Address :'.$address.'<br> Ico : '.$ico.'<br>Amount : '.$amount ;
?>
结果: