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);

Link to comment
Share on other sites

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.

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.