Consume

product 生产出来的数据,会投递consume任务数据在jobData中

  1. <?php
  2. namespace App\Spider;
  3. use EasySwoole\Spider\ConsumeJob;
  4. use EasySwoole\Spider\Hole\ConsumeAbstract;
  5. class ConsumeTest extends ConsumeAbstract
  6. {
  7. public function consume()
  8. {
  9. // TODO: Implement consume() method.
  10. $data = $this->getJobData();
  11. $items = '';
  12. foreach ($data as $item) {
  13. $items .= implode("\t", $item)."\n";
  14. }
  15. file_put_contents('baidu.txt', $items, FILE_APPEND);
  16. }
  17. }