VanGans

Gmail IMAP Scrapper

Apr 19th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2.     $email = array(
  3.             'host'      => '{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX',
  4.             'username'  => 'email@gmail.com',
  5.             'password'  => 'password'
  6.         );
  7.  
  8.      $read  = imap_open($email['host'],$email['username'],$email['password']);
  9.      $array = imap_search($read,'SUBJECT "BIGtoken" UNSEEN');
  10.      
  11.      if($array==null){
  12.         echo 'Link Token Not Found!';
  13.         echo PHP_EOL;
  14.      }else{
  15.  
  16.      foreach($array as $a){
  17.         $header = imap_header($read, $a);
  18.         $html = imap_qprint(imap_fetchbody($read, $a, 1));
  19.        
  20.         $dom = new DOMDocument;
  21.         @$dom->loadHTML($html);
  22.         $links = $dom->getElementsByTagName('a');
  23.         $link = $links[1]->getAttribute('href')."\n";  
  24.         file_put_contents('link.txt', $link, FILE_APPEND | LOCK_EX);
  25.         echo 'Link Found => ' .$link;
  26.      }
  27. }
  28. ?>
Add Comment
Please, Sign In to add comment