<?php

namespace App\Http\Controllers;

use App\Model\Communite;
use Illuminate\Http\Request;
use QL\QueryList;

class IndexController extends Controller
{
    public function index()
    {
//$domain = 'https://cd.lianjia.com/xiaoqu';
        set_time_limit(1800);
        for($i=1;$i<100;$i++){
            $areas = QueryList::get('https://cd.lianjia.com/xiaoqu'.$i,null,[
                'headers' => [
                    'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
                    'Accept-Encoding' => 'gzip, deflate, br',
                ]
            ])->find('.position a')->attrs('href');
            dd($areas);
            foreach ($areas as $area){
                Communite::insert(['links'=>$area]);
            }
        }
dd($area);
        $link = QueryList::get('https://cd.lianjia.com/xiaoqu/1611043165264', null, [
            'headers' => [
                'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
                'Accept-Encoding' => 'gzip, deflate, br',
            ]
        ])->getHtml();
        if($link)
        dd($link->getHtml());
        $info = QueryList::get('https://cd.lianjia.com/xiaoqu/1611043165264', null, [
            'headers' => [
                'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36',
                'Accept-Encoding' => 'gzip, deflate, br',
            ]
        ])->find('.xiaoquDescribe')->htmls();

        dd($info);
    }
}
