我努力讓自己在這裏PHP捲曲登錄和獲取數據
https://login.comcast.net/login
的PHP應用程序,用於登錄Comcast和下載文件
http://xfinity.comcast.net/
記住餅乾。
這是我到目前爲止有:
<?php
$username="username";
$password="password";
$url="https://login.comcast.net/login";
$cookie="cookie.txt";
$postdata = "user=".$username."&passwd=".$password."&rm=2&deviceAuthn=false&forceAuthn=true&s=ccentral-cima&r=comcast.net&continue=http://xfinity.comcast.net/";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
echo $result;
curl_close($ch);
file_put_contents("page.txt",$ch);
echo $cookie;
?>
什麼這個腳本不只是登錄,並告訴我
https://customer.comcast.com/Public/Home.aspx
因爲我是登錄,然後當我按下電子郵件的例如它簡單地對待我像我從未登錄,要求我的用戶名和密碼。我想要的是通過將http://xfinity.comcast.net/(帶有cookie)保存到page.txt中來獲取電子郵件的數量
這可能嗎?
我有點困惑:首先,您通過CURL將cookie登錄到cookie.txt中,然後嘗試打開_browser_中的頁面,希望它會在cookie.txt中查找cookie ? – raina77ow 2012-02-26 17:39:03
您是否嘗試過使用'CURLOPT_AUTOREFERER'和'CURLOPT_REFERER'選項? – h0tw1r3 2012-02-26 17:39:54
你是對的raina77ow,你有一個點 – Master345 2012-02-26 18:11:14