Jump to content

Dynamically pulling data from one page to another


rammac13

Recommended Posts

you can use cURL to submit form data, then the session and cookies are

 

/**
* cURL Quick Client
*
* @param string $url URL To access
* @param array $postdata Data Array to Send to Page in POST Form
* @param string $refer Referring URL
* @return string HTML Document or Text returned from the site.
*/
function gethtml($url, $postdata = false, $refer = false) {
	$ch = curl_init(); 
		curl_setopt($ch, CURLOPT_URL,$url );
		curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
		if($postdata) {
			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);
		}
		curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12");
		curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_REFERER, $refer);
		curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
	$html = curl_exec ($ch);
    curl_close($ch);
	return $html;
}

$content = gethtml($url, $postdata, $refer);
echo($content);

Personally I would just use AJAX for this.  If you are using a decent framework like mootools/jquery it would be simple.  You can even grab a table from a page by using its ID and not have to parse the whole page or use a lot of php code filtering what you don't want to appear.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.