mardi 30 mai 2017

Laravel Guzzle getting destination and due time from a page

I want my website to scrape information from this page http://ift.tt/2rRckbS and in particular I want to scrape destination and due time from that website and give me an output.

At this moment my controller looks like this:

function guzzle(){
$client = new \GuzzleHttp\Client();
$results = $client->get('http://ift.tt/2riWRk3');
//$result->getBody();
//return view('hello')->with('results', $results);
//dd($result);
$results->getBody()->getContents();
dd($results);
return view('hello');
}

And the output is:

Response {#190 ▼
  -reasonPhrase: "OK"
  -statusCode: 200
  -headers: array:8 [▼
    "Content-Security-Policy" => array:1 [▶]
    "Content-Type" => array:1 [▶]
    "Date" => array:1 [▶]
    "ETag" => array:1 [▶]
    "X-Content-Security-Policy" => array:1 [▶]
    "X-WebKit-CSP" => array:1 [▶]
    "Content-Length" => array:1 [▶]
    "Connection" => array:1 [▶]
  ]
  -headerNames: array:8 [▼
    "content-security-policy" => "Content-Security-Policy"
    "content-type" => "Content-Type"
    "date" => "Date"
    "etag" => "ETag"
    "x-content-security-policy" => "X-Content-Security-Policy"
    "x-webkit-csp" => "X-WebKit-CSP"
    "content-length" => "Content-Length"
    "connection" => "Connection"
  ]
  -protocol: "1.1"
  -stream: Stream {#188 ▶}
}

However how can I access specific html class, scrape information from it and output it on my page?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2r7GW7L
via IFTTT

Aucun commentaire:

Enregistrer un commentaire