如何使用php-ccurl登录此网站



我正试图在这里登录http://www.wemakeprice.com/通过curl,但我不知道在哪里发送登录数据,在哪里接收登录cookie

有些网站很容易,因为可以在开发者工具中通过网络点击查看发送到登录表单数据的位置

但该网站是cen找不到我发送数据登录的地方。

我正在寻找有关这个问题的有用文档

你能给我建议吗?

谢谢你的光临。

试试我写的这个片段,将用户名和密码替换为相应的凭据,并将URL替换为要从中获取数据的页面(需要登录的页面(。

检查在浏览器检查器中发送的帖子数据。将$postinfo替换为正确的post数据,以确保发送的数据正确。"电子邮件"one_answers"密码"作为$postdata可能不适用于您试图登录的网站。如果您遇到问题,请将网络选项卡中报告的检查员数据发布出来,我会尽力提供帮助。

$username = "email@example.com";
$password = "MyPassword123";
$dir = $_SERVER['DOCUMENT_ROOT']."/ctemp";
$path = tempnam(sys_get_temp_dir(), 'MyTempCookie');
$url = "https://www.example.com/dashboard/";
$postinfo = "email=".$username."&Password=".$password;
$cookie_file_path = $path."/cookie.txt";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_NOBODY, false);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
//for certain features, set the cookie the site has - this is optional
curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
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_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $url);
$html_data = curl_exec($ch);
curl_close($ch);
echo $html_data;

最后,我只是简单地回显返回的html数据。但你可以用它做任何你想做的事情,并在你需要的响应中搜索数据。

编辑:刚刚看到网站有他们登录过程的摘要。现在,通过cURL登录将变得更加复杂,因为它们会在图像中向您显示repatcha代码。可能想看看关于欺骗重述数据的教程。祝你好运

最新更新