Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Laravel-zeroで楽して情報収集する?

maki
February 16, 2019

 Laravel-zeroで楽して情報収集する?

maki

February 16, 2019
Tweet

More Decks by maki

Other Decks in Technology

Transcript

  1. public function handle() { $this->browse(function($browser) { // login $browser->visit('https://site1.test/login') ->type('email',

    config('service.site1_email')) ->type('password', config('service.site1_password')) ->press('Login'); // get text $text = $browser->text('#app > main > div > div > div > div > div.card-body'); \Log::info($text); $this->notify(‘Hello Web Artisan’, $text, 'icon.png'); }); }
  2. $ php zero site1:login Visit https://site1.test/login: ✔ Type email [email protected]:

    ✔ Type password secret!: ✔ Press Login: ✔ Text #app > main > div > div > div > div > div.card-body: ✔ [2019-02-16 03:30:24] development.INFO: You are logged in!
  3. $this->browse(function($browser) { // login $browser->visit('https://site1.test/login') ->type('email', config('service.site1_email')) ->type('password', config('service.site1_password')) ->press('Login');

    // get text $text = $browser->text('#app > main > div > div > div > div > div.card-body'); // slack post $guzzle = new \GuzzleHttp\Client(); $guzzle->post(config('service.slack.webhook_url'), [ 'body' => json_encode([ 'channel' => config('service.slack.channel'), 'text' => $text, 'username' => config('service.slack.username'), 'icon_emoji' => config('service.slack.icon'), ]), ]); });
  4. $ php zero site1:slack Visit https://site1.test/login: ✔ Type email [email protected]:

    ✔ Type password password: ✔ Press Login: ✔ Text #app > main > div > div > div > div > div.card-body: ✔ Screenshot login: ✔
  5. $this->task('get site1', function () { $this->browse(function ($browser) { // login

    $browser->visit('https://site1.test/login') ->type('email', config('service.site1_email')) ->type('password', config('service.site1_password')) ->press('Login'); // get text $this->site1['text'] = $browser->text('#app > main > div > div > div > div > div.card-body'); $browser->screenshot('login'); $this->site1['screenshots'] = storage_path('laravel-console-dusk/screenshots') . '/login.png'; }); });
  6. $this->task('upload to s3', function () { // upload to s3

    $guzzle = new \GuzzleHttp\Client(); $gyazo = $guzzle->post(config('service.gyazo.url'), [ 'headers' => [ 'content-type' => 'image/png', 'x-api-key' => config('service.gyazo.api_key') ], 'body' => fopen($this->site1['screenshots'], 'r'), ]); if (200 !== $gyazo->getStatusCode()) { throw new \Exception('s3 upload failed.'); } $this->imageUrl = $gyazo->getBody()->getContents(); });
  7. $this->task('post slack', function() { // slack message $payload = [

    'channel' => config('service.slack.channel'), 'text' => $this->site1['text'], 'username' => config('service.slack.username'), 'icon_emoji' => config('service.slack.icon'), 'attachments' => [ [ 'image_url' => $this->imageUrl, 'color' => 'good' ] ] ]; $guzzle = new \GuzzleHttp\Client(); $guzzle->post(config('service.slack.webhook_url'), [ 'body' => json_encode($payload), ]); });
  8. $ php zero site1:slack-image Visit https://site1.test/login: ✔ Type email [email protected]:

    ✔ Type password password: ✔ Press Login: ✔ Text #app > main > div > div > div > div > div.card-body: ✔ Screenshot login: ✔ get site1: ✔ upload to s3: ✔ post slack: ✔
  9. ΞΠσΟΞ w ۈଵ؅ཧγεςϜ ύϒϦοΫͳ"1*ͳͲͳ͍ʜ  w ฏ೔༦ํʹಈ͘ w ϑΥʔϜϩάΠϯ w

    λΠϜΧʔυը໘Λ։͘ w ࠓ೔ͷग़ۈ࣌ࠁΛऔಘ w ࠓ݄ͷ࿑ಇ࣌ؒɺ೔ฏۉΛܭࢉ w σεΫτοϓTMBDL௨஌
  10. ΞΠσΟΞ w ۀ຿ใࠂγεςϜ ύϒϦοΫͳ"1*ͳͲͳ͍ʜ  w ೔ճ ேPS༦ํ  w

    ϑΥʔϜϩάΠϯ w ը໘ʹදࣔ͞ΕΔܯࠂΛऔಘঝೝґཔະ֬ఆ w σεΫτοϓTMBDL௨஌