0
要登录该站点,我已经使用过了。但成功登录后,我怎么能重定向到一个页面,因为我想在网站上。要登录网站并登录后重定向到php curl的页面
对于通过php卷曲登录我用这个。
$loginUrl = 'https://secure.propertyshark.com/mason/Accounts/logon.html';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $loginUrl);
curl_setopt($ch, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "[email protected]&password=mypassword");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
$cookie = getcwd().DIRECTORY_SEPARATOR.'cookie.txt';
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
$answer = curl_exec($ch);
if (curl_error($ch)) {
echo curl_error($ch);
}
curl_setopt($ch, 'http://www.propertyshark.com/mason/Property/619443/133-32-244-St-Queens-NY-11422/');
echo $answer;
,但我不知道它是否工作,所以我想我怎么能确认有关登录和重定向到“” http://www.propertyshark.com/mason/Property/619443/133-32-244-St-Queens-NY-11422/”页面。
现在我正在使用这个,但不工作。
<?php
$loginUrl = 'https://secure.propertyshark.com/mason/Accounts/logon.html';
$ch1 = curl_init();
$cookie = getcwd().DIRECTORY_SEPARATOR.'cookie.txt';
curl_setopt($ch1, CURLOPT_URL, $loginUrl);
curl_setopt($ch1, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch1, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_USERAGENT,'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
curl_setopt($ch1, CURLOPT_POST, true);
curl_setopt($ch1, CURLOPT_POSTFIELDS, "[email protected]&password=password");
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch1, CURLOPT_COOKIESESSION, true);
$next_page = 'http://www.propertyshark.com/mason/Property/619443/133-32-244-St-Queens-NY-11422/';
$ch2 = curl_init();
$cookie = getcwd().DIRECTORY_SEPARATOR.'cookie.txt';
curl_setopt($ch2, CURLOPT_URL, $next_page);
curl_setopt($ch2, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch2, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, false);
$answer = curl_exec($ch2);
if (curl_error($ch2)) {
echo curl_error($ch2);
}
echo $answer;
我应该添加此的脚本和创建的cookie .txt文件? – Ranjit
添加到脚本中,不需要缓存cookies.txt ...自动创建 – CatalinB
如何重定向页面?我认为,这需要花费太多时间还是不行?我已经用脚本添加了这个问题。请检查 – Ranjit