Getting content from one site and inserting to our database in PHP


               include 'simple_html_dom.php'; // plugin for html parser with php
		$curl = curl_init(); // initializing command line tool url
		curl_setopt ($curl, CURLOPT_URL, "urlname"); // setting up to the target url
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)");
		curl_setopt($curl, CURLOPT_AUTOREFERER, 1);
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($curl, CURLOPT_REFERER, "urlname");

		$result = curl_exec ($curl);
		curl_close ($curl);
		//write contents of $result to file
		$File = "video_show.html";
		$fh = fopen($File, 'w') or die("can't open file");
		fwrite($fh, $result);
		fclose($fh);
		$page = file_get_html("video_show.html"); 	//turn file into dom object
		$header = $page->find('table');
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s