I am trying to recieve the html source of a page that requires me to get a sessionID. The code I am using is this:

<?php

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/pscookie.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/pscookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://myplanetside.station.sony.com/outfit.jsp?outfitId=14812&worldId=15");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
$buf2 = curl_exec ($ch);
curl_close ($ch);
echo "<PRE>".htmlentities($buf2);
?>

When I was using fopen I would recieve an http request failed error while with this code I actually recieve the html from the source. The only problem it is not all of it... not even close to all of the html. This is all I recieve:

<html><!-- InstanceBegin template="/Templates/subpage.dwt.jsp" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>PlanetSide - My PlanetSide - Outfit</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="Code" -->

<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="/planetside.css" rel="stylesheet" type="text/css">
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
</head>
<body bgcolor="black" text="white" leftmargin="0" rightmargin="0" topmargin="0" bottommargin="0">

<div style="position: absolute; z-index: -1; top:0px; left:0px; width: 100%">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="900" height="46" background="/images/base/nav_left.gif">
<tr>
<td width="50%" background="/images/base/nav_left.gif">&nbsp;</td>
<td width="50%" background="/images/base/nav_right.gif">&nbsp;</td>
</tr>
</table>
</center>
</div>

<center>
<table border="0" cellspacing="0" cellpadding="0" width="780"><tr><td>

This is the top portion of the code but for some reason I can't get the rest of it. I'm utterly stumped and am begging for any help at all.

If you want to see all the code I want to get view the source of: http://myplanetside.station.sony.com/outfit.jsp?outfitId=14812&worldId=15

bradley193

    hey,
    i played with it for a while and figured out your problem.

    that site is checking for a user agent so it knows how to display content i guess.

    add this to your code and it should work

    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20031007");

      Write a Reply...