第五步:设定业务规则

1、首先切换到应用配置目录:
cd Application/Spider/Weather/Config/
2、回过头来重新编辑 main.php:

假定业务需求是:抓取未来7天之内的天气预报,所以设定好业务规则后的简化样板代码如下:

return array(
    'task' => array(
        'url' => array(
            "r1" => "http://www.weather.com.cn/weather/101010100.shtml",
        ),
        'rule' => array(
            "r1" => array(
                'time' => ['div#7d ul.t.clearfix h1',      'text'],
                'wea'  => ['div#7d ul.t.clearfix p.wea',   'text'],
                'tem'  => ['div#7d ul.t.clearfix p.tem',   'text'],
                'wind' => ['div#7d ul.t.clearfix p.win i', 'text'],
            ), 
        ),
   ),
);

results matching ""

    No results matching ""