Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created June 18, 2015 06:14
Show Gist options
  • Save bangpound/06fb6a41d447afabdad3 to your computer and use it in GitHub Desktop.
Save bangpound/06fb6a41d447afabdad3 to your computer and use it in GitHub Desktop.
<?php
<<<CONFIG
packages:
- "guzzlehttp/guzzle: ~6.0"
- "symfony/dom-crawler: ~2.7"
- "symfony/css-selector: ~2.7"
- "symfony/console: ~2.7"
CONFIG;
$client = new GuzzleHttp\Client();
$response = $client->get('https://twitter.com/'. $argv[1]);
$body = $response->getBody();
$tail = substr($body, strpos($body, '</html>') + strlen('</html>'));
if (!empty($tail)) {
$crawler = new Symfony\Component\DomCrawler\Crawler($tail);
$values = $crawler->filter('input#init-data.json-data')->extract('value');
$data = json_decode($values[0], TRUE);
$profile = $data['profile_user'];
print_r($profile);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment