How to insert scraping data to mysql
Posted
by
user1887288
on Stack Overflow
See other posts from Stack Overflow
or by user1887288
Published on 2012-12-13T04:57:47Z
Indexed on
2012/12/13
5:03 UTC
Read the original article
Hit count: 80
i am fetching data from other websites can any one tell me how to insert fetch data to mysql database
Below code i am using to fetch results coming
$urls = $_POST["urls"];
require_once('simple_html_dom.php');
$useragent = 'Googlebot/2.1 (http://www.googlebot.com/bot.html)';
foreach ($urls as $url)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($curl, CURLOPT_USERAGENT, $useragent);
$str = curl_exec($curl);
curl_close($curl);
$html= str_get_html($str);
foreach($html->find('span.price') as $e)
echo $e->innertext . '<br>';
}
© Stack Overflow or respective owner