How to insert scraping data to mysql
- by user1887288
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>';
}