Esempio n. 1
0
 /**
  * 显示内容
  * @param $name
  * @param $id
  * @return mixed
  * @author Mr.Cong <*****@*****.**>
  */
 public function show($name, $id)
 {
     /*
      * 开始查询数据
      */
     switch ($name) {
         case 'forums':
             $post = Forums::find($id);
             break;
         case 'news':
             $post = News::find($id);
             break;
         default:
             break;
     }
     return view('show')->with('post', $post)->with('name', $name);
 }
Esempio n. 2
0
 /**
  * 显示内容
  * @param $name
  * @param $id
  * @return mixed
  * @author Mr.Cong <*****@*****.**>
  */
 public function show($name, $id)
 {
     /*
      * 开始查询数据
      */
     switch ($name) {
         case 'forums':
             $post = Forums::find($id);
             $post = $post->content = body_replace_with_forums_by_json($post->content);
             break;
         case 'news':
             $post = News::find($id);
             break;
         default:
             break;
     }
     return Response::json($post);
 }
Esempio n. 3
0
 /**
  * 采集HTML内容 [没有使用]
  * @param $tid
  * @param $id
  * @author Mr.Cong <*****@*****.**>
  */
 public function getContent($tid, $id)
 {
     $this->id = $id;
     $url = sprintf('http://www.chinagdg.com/thread-%s-1-1.html', $tid);
     $client = new Goutte\Client();
     $crawler = $client->request('GET', $url);
     // 抓取class=".t_fsz" 的div标签内的第一条内容
     $dom = $crawler->filter('.t_fsz');
     $thread = Forums::find($this->id);
     //先查询
     $thread->content = body_replace_with_forums_by_html($dom->html());
     //然后更新到数据库
     $thread->save();
 }