378 发表于 2018-12-14 09:55:52

php爬虫:知乎用户数据爬取和分析

  // 获取用户头像
  preg_match('//i', $str, $match_img);
  $img_url = $match_img;
  // 匹配用户名:
  // 崔小拽
  preg_match('/([\x{4e00}-\x{9fa5}]+).+span>/u', $str, $match_name);
  $user_name = $match_name;
  // 匹配用户简介

  //>  preg_match('/([\x{4e00}-\x{9fa5}]+).+span>/u', $str, $match_title);
  $user_title = $match_title;
  // 匹配性别
  // 男  
  // gender value1 ;结束 中文
  preg_match('/(\d+)\s.+strong>/i', $str, $match_topic);
  $user_topic = $match_topic;
  // 关注人数
  // 关注了
  preg_match_all('/(\d+)(\d+)/i', $str, $match_browse);
  $user_browse = $match_browse;

页: [1]
查看完整版本: php爬虫:知乎用户数据爬取和分析