我想存储:
在我的名为products_data的表中,其filds名称为PID,product_name,category,subcategory,product_price和product_company.
我curl_init()在php中使用函数首先废弃网站URL,接下来我想将产品数据存储在我的数据库表中.以下是我迄今为止所做的事情:
$sites[0] = 'http://www.babyoye.com/';
foreach ($sites as $site)
{
$ch = curl_init($site);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec($ch);
$title_start = '<div class="info">';
$parts = explode($title_start,$html);
foreach($parts as $part){
$link = explode('<a href="/d/', $part);
$link = explode('">', $link[1]);
$url = 'http://www.babyoye.com/d/'.$link[0];
// now for the title we need to follow a similar process:
$title = explode('<h2>', $part);
$title = explode('</h2>', $title[1]);
$title = strip_tags($title[0]);
// INSERT DB CODE HERE e.g.
$db_conn = …Run Code Online (Sandbox Code Playgroud)