无法使用CURL管理会话

无法使用CURL管理会话,curl,Curl,希望一切顺利 我需要一点帮助 我正试图用卷曲的纸刮一页(http://wap.ebay.com/Pages/ViewItem.aspx?aid=160585148382),当加载此页面时,该页面中有另一个链接(锚文本:Description),我也想刮除该页面 当您直接进入描述页面时(http://wap.ebay.com/Pages/ViewItemDesc.aspx?aid=280655395879&emvcc=0)把你的浏览器,它会显示你的错误,如“会话过期或没有拍卖的细节发现”,我想刮该

希望一切顺利

我需要一点帮助

我正试图用卷曲的纸刮一页(http://wap.ebay.com/Pages/ViewItem.aspx?aid=160585148382),当加载此页面时,该页面中有另一个链接(锚文本:Description),我也想刮除该页面

当您直接进入描述页面时(http://wap.ebay.com/Pages/ViewItemDesc.aspx?aid=280655395879&emvcc=0)把你的浏览器,它会显示你的错误,如“会话过期或没有拍卖的细节发现”,我想刮该页,我们需要有一些会话或一些东西

所以,首先我想抓取&然后在Description按钮中提取URL,然后是Prefix(http://wap.ebay.com/Pages)对它进行复制,使其成为完整的URL,然后我想对该URL的内容进行Srape

但看起来我无法保持会话的有效性

我的代码是:

<?
require_once('simple_html_dom.php');

$url = 'http://wap.ebay.com/Pages/ViewItem.aspx?aid=160585148382';
$ch = curl_init($url);
curl_setopt ($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$curl_scraped_page = curl_exec($ch);
curl_close($ch);

//echo $curl_scraped_page;

$html = str_get_html($curl_scraped_page);

 // Find the img tag in the Teaser_Item div
 $a = $html->find('div[id=Teaser_Item] img', 0);

 // Display the src
 $e_image = 'http://wap.ebay.com/Pages/'.str_replace("width=57", "width=200", ($a->attr['src']));
 echo '<img src="'.$e_image.'" /> <br /><br />';


$wow = $html->find('a#ButtonMenuItem3', 0);

 $descurl = 'http://wap.ebay.com'.$wow->attr['href'];
 echo $descurl;


 exit;

 $html->clear();
 unset($html);


$html = file_get_html($descurl);

 echo $html;




$html->clear();
unset($html);


?>

干杯
Natasha

您没有将$cookie设置为值,因此
CURLOPT\u COOKIEFILE
/
CURLOPT\u COOKIEJAR
两者都为空,因此不保存。

您没有将$cookie设置为值,因此
CURLOPT\u COOKIEFILE
/
CURLOPT\u COOKIEJAR
两者都为空,因此不保存

  $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
  session_write_close();
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt( $ch, CURLOPT_COOKIE, $strCookie );