Created
May 29, 2012 14:29
-
-
Save sasezaki/2828746 to your computer and use it in GitHub Desktop.
Goutte Wrapper by Diggin_Http_Charset for CP932
This file contains hidden or 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 | |
| use Goutte\Client; | |
| use Guzzle\Http\Message\Response as GuzzleResponse; | |
| use Symfony\Component\BrowserKit\Response; | |
| use Diggin\Http\Charset\WrapperFactory; | |
| class GoutteWrapper extends Client | |
| { | |
| protected function createResponse(GuzzleResponse $response) | |
| { | |
| $response = new Response($response->getBody(true), $response->getStatusCode(), $response->getHeaders()->getAll()); | |
| return WrapperFactory::factory($response); | |
| } | |
| } | |
| $url = 'http://www.kms.gol.com/benkyo/ben1.htm'; | |
| if (isset($argv[1])) { | |
| $client = new GoutteWrapper; | |
| } else { | |
| $client = new Client; | |
| } | |
| $crawler = $client->request('GET', $url); | |
| $title = $crawler->filterXpath('//title')->text(); | |
| echo $title; // ①文書情報マネジメントとは? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment