Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2.  
  3. $keywords = 'high';
  4. print("starting pid::  ");
  5. $from     = (int)fgets(STDIN);
  6. print("ending pid::  ");
  7. $to       = (int)fgets(STDIN);
  8.  
  9. set_time_limit( 0 );
  10.  
  11. $curl = curl_init();
  12. curl_setopt( $curl, CURLOPT_AUTOREFERER, true );
  13. curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, false );
  14. curl_setopt( $curl, CURLOPT_HEADER, false );
  15. curl_setopt( $curl, CURLOPT_NOBODY, true );
  16. curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
  17. curl_setopt( $curl, CURLOPT_USERAGENT, 'Opera/9.80 (Windows NT 6.0; U; en) Presto/2.2.15 Version/10.10' );
  18. $keywords = explode( ' ', strtolower( $keywords ) );
  19. $links = 0;
  20. $log = fopen( dirname( __FILE__ ) . '/barneys.log', 'w' );
  21. for ( $i = $from ; $i <= $to ; $i ++ ) {
  22.     curl_setopt( $curl, CURLOPT_URL, 'http://www.barneys.com/' . $i . '.html' );
  23.     echo $i;
  24.     //   if ( $i % 25 == 0 ) {
  25.         fwrite( $log, 'position=' . $i . ', found=' . $links . "\n" );
  26.         fflush( $log );
  27.     // }
  28.         $response = curl_exec( $curl );
  29.         $info = curl_getinfo( $curl );
  30.     if ( $info[ 'http_code' ] == 403) {
  31.         echo 'banned';
  32.         break; 
  33.     }
  34.     if ( $info[ 'http_code' ] == 301 && ( $pos = strrpos( $info[ 'redirect_url' ], '/' ) ) !== false ) {
  35.             $found = true;
  36.             foreach ( $keywords as $keyword ) {
  37.                     if ( strpos( substr( $info[ 'redirect_url' ], $pos ), $keyword ) === false ) {
  38.                         $found = false;
  39.                         break;
  40.                     }
  41.             }
  42.             if ( $found ) {
  43.             echo ' :: ';
  44.                     echo $info[ 'redirect_url' ] ;
  45.                     $links ++;
  46.             }
  47.         }
  48.     echo "\n";
  49.         sleep(rand(.5,1.5));
  50. }
  51. fclose( $log );
  52. curl_close( $curl );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement