2019-04-14 08:42
浏览 103


I am trying to retrieve information from an external website using cURL, but the website returns a blank page.

I took a close looker at the network functionality Chrome has and I think I found the problem, but I have no idea how to fix it. As seen in the image below, the server posts to a specific URL and then redirects to another one showing the final result.

This is the code I have right now:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL,"");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,"url=&query=test");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

echo curl_exec ($ch);

curl_close ($ch);

The website is in Dutch, but what I am trying to do is check a certain email, phone number or bank account number to see if they have been involved in any scams, so I would like to have the information that a user gets after submitting the form on the website.

The form is on this website:

I hope someone can help me and thank you for your time.

图片转代码服务由CSDN问答提供 功能建议


我仔细观察了Chrome的网络功能,我认为我发现了问题,但我不知道如何修复它。 如下图所示,服务器发布到特定URL,然后重定向到另一个显示最终结果的URL。


  $ ch = curl_init(); 
curl_setopt($ ch,CURLOPT_URL,“”); 
curl_setopt(  $ ch,CURLOPT_POST,1); 
curl_setopt($ ch,CURLOPT_POSTFIELDS,“url =& query = test”); 
curl_setopt($ ch,CURLOPT_HTTPHEADER,array('Content-Type:application / x-www-form-  urlencoded')); 
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,true); 
echo curl_exec($ ch); 
 ncurl_close($ ch); 
 <  p>该网站是荷兰语,但我要做的是检查某个电子邮件,电话号码或银行帐号,看看他们是否参与了任何sc  ams,所以我希望获得用户在网站上提交表单后获得的信息。 

表格在本网站上: < / a>


  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doujia6503 2019-04-14 10:17

    As was pointed out in one of the comments to your question, a redirect occurs after the form is submitted. But not only that - information transfer between the form submit request and the request after redirect happens through a session, with session id stored in a cookie, so in order to get the results you have to enable cookies, too.

    // follow redirects
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    // store and send cookies
    $tmpfname = dirname(__FILE__).'/cookie.txt';
    curl_setopt($ch, CURLOPT_COOKIEJAR, $tmpfname);
    curl_setopt($ch, CURLOPT_COOKIEFILE, $tmpfname);
    打赏 评论

相关推荐 更多相似问题