Jump to content

Detect Variables


fanfavorite

Recommended Posts

I am trying to get information from a particular website and I can output the entire website, however one section seems to display differently when I use cURL compared to when I go directly to the URL.  The code is: 

 

<?
$URL1 = "http://www.domain.com/"; //ASP Website
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);  
curl_setopt($ch, CURLOPT_TIMEOUT,3);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1); 
curl_setopt($ch, CURLOPT_URL,$URL1); 

if ($buffer = curl_exec($ch)) {
echo $buffer;
}     
curl_close ($ch); 
?>

 

Is there a way to figure out what might be causing the different data to display? 

Link to comment
Share on other sites

Try going to http://www.machosports.com/VwSportSelection.asp and then seeing what http://www.machosports.com/VwSportSelection.asp shows.  Just the middle content is what is changed.  Radio buttons for the middle content through curl, when they are href for other.  It also doesn't have one of the key variables tmpPeriod. 

Link to comment
Share on other sites

The only part of the code that is different is the middle form "SportSelectionForm".  This is what I don't understand, so Third_Degree is right, but I don't know how to fix this.  I thought that cURL reads it as if you were to just go to the website.  The only other thing that is in my code that is not listed above is some str_replaces to add the full url.  They are irrelevent to post because if I leave them out, it still shows the middle section how it is, just doesn't have any of the other layout proper. 

 

What is displayed would be fine if I could get the tmpPeriod value, which does not display on the cURL page. 

 

I don't really know where to go from here to get that.  file_get_contents is normally what I would use, but for some reason some asp pages give you a 500 Internal Server Error with that.   

Link to comment
Share on other sites

I already did that.  That is http://www.anothertakestudios.com/test.php.  Unless I am not understanding you correctly: 

 

$URL1 = "http://www.machosports.com/VwSportSelection.asp";

$ch = curl_init();

curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");

curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 

curl_setopt($ch, CURLOPT_TIMEOUT,3);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);

curl_setopt($ch, CURLOPT_URL,$URL1);

 

if ($buffer = curl_exec($ch)) {

preg_match_all("/.sportType.value = '(.*)'/Uis",$buffer, $matches);

preg_match_all("/.sportSubType.value = '(.*)'/Uis",$buffer, $matches2);

preg_match_all("/.tmpPeriod.value = '(.*)'/Uis",$buffer, $matches3);

$counter = 0;

foreach ($matches[1] as $match) {

//echo $counter.": ".$match;

//echo ",".$matches2[1][$counter];

//echo ",".$matches3[1][$counter];

//echo "<br />";

$counter++;

}

$buffer = str_replace('href="','href="http://www.machosports.com',$buffer);

$buffer = str_replace('name="movie" value="','name="movie" value="http://www.machosports.com/',$buffer);

$buffer = str_replace('embed src="','embed src="http://www.machosports.com/',$buffer);

$buffer = str_replace('script src="','script src="http://www.machosports.com',$buffer);

$buffer = str_replace('myFlashObject.movie="','myFlashObject.movie="http://www.machosports.com/',$buffer);

$buffer = str_replace('IMG SRC="','IMG SRC="http://www.machosports.com/',$buffer);

$buffer = str_replace('img src="','img src="http://www.machosports.com/',$buffer);

$buffer = str_replace('type="text/javascript" src="','type="text/javascript" src="http://www.machosports.com/',$buffer);

$buffer = str_replace('cellspacing="0" background="','cellspacing="0" background="http://www.machosports.com/',$buffer);

$buffer = str_replace('type="image" src="','type="image" src="http://www.machosports.com/',$buffer);

echo $buffer;

}   

curl_close ($ch);

Link to comment
Share on other sites

I don't see how the CSS will change source code.  It's not the overall look that I care about, its the actual data.  The only thing CSS can do is hide layers.  Now I reviewed that site.css and there is nothing in there with any significance to my problem.  It is linked fine in the curl request too.   

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.