相关疑难解决方法(0)

如何在数据库中添加被删除的网站数据?

我想存储:

  1. 产品名称
  2. Categoty
  3. 子目录
  4. 价钱
  5. 产品公司.

在我的名为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)

php curl web-scraping

-2
推荐指数
1
解决办法
5358
查看次数

标签 统计

curl ×1

php ×1

web-scraping ×1