Created
July 10, 2014 13:44
-
-
Save afutseng/7b8f0dba567ef951a8dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require '../vendor/autoload.php'; | |
+ use GuzzleHttp\Client; | |
+ use GuzzleHttp\Cookie\CookieJar; | |
+ | |
+ | |
+ $url = 'https://www.ptt.cc/bbs/Gossiping/M.1404887907.A.886.html'; | |
$client = new Client(); | |
+ | |
+ $jar = new CookieJar(); | |
+ $client->setDefaultOption('cookies', $jar); | |
+ | |
+ try { | |
+ $response = $client->post('https://www.ptt.cc/ask/over18', [ | |
+ 'body' => [ | |
+ 'yes' => 'yes', | |
+ 'from' => '/bbs/Gossiping/M.1404887907.A.886.html' | |
+ ] | |
+ ])->getBody(); | |
+ } catch (Exception $e) { | |
+ echo $e->getMessage() . PHP_EOL; | |
+ } | |
+ | |
$response = $client->get($url)->getBody(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment