/** * @return category page single link url data eg.mobile, email etc */ public function getData() { $link = Link::first(); //$ua = 'Mozilla/5.0 (Windows NT 5.1; rv:16.0) Gecko/20100101 Firefox/16.0 (ROBOT)'; $client = new Client(); $client->setHeader('User-Agent', "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36"); //Set proxy using tor $guzzleClient = new \GuzzleHttp\Client(['curl' => [CURLOPT_PROXY => '127.0.0.1:9050', CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5]]); $client->setClient($guzzleClient); $crawler = $client->request('GET', $link->url); //$button = $crawler->filter('.reply_button'); $isBlock = $crawler->filter('p')->text(); $isRun = true; $i = 0; while ($isRun) { if (strpos($isBlock, 'blocked') != false) { $this->torNew(); //return $this->getIndex(); $crawler = $client->request('GET', $link->url); $isBlock = $crawler->filter('p')->text(); } else { $lnk = $crawler->selectLink('reply')->link(); $crawler = $client->click($lnk); if ($crawler->filterXpath("//div[@class='captcha']")->count()) { $this->torNew(); } else { var_dump($crawler->html()); $title = $crawler->filter('title')->text(); $mobile = $crawler->filter('.mobile-only')->first()->text(); $email = $crawler->filter('.mailapp')->first()->text(); echo $link->url . ' ' . $title . ' ' . $mobile . ' ' . $email; Scrap::create(['url' => $link->url, 'title' => $title, 'email' => $email, 'phone' => $mobile]); $isRun = false; } } } //End While // $crawler->filter('a.i')->each(function ($node) { // $url = $node->attr("href")."\n"; // //$link = $node->filter('a')->first(); // $text = $node->text(); // $fullUrl = "http://auburn.craigslist.org".$url; // //$scrap::create(['url' => $url, 'title' => $text ]); // Link::create(['url'=>$fullUrl, 'title'=> $text]); // var_dump($url); // $this->tor_new_identity(); // }); }