Navigazione

    Privacy - Termini e condizioni
    © 2020 Search On Media Group S.r.l.
    • Registrati
    • Accedi
    • CATEGORIES
    • Discussioni
    • Non letti
    • Recenti
    • Hashtags
    • Popolare
    • Utenti
    • Stream
    • Interest
    • Categories
    1. Home
    2. bjng
    3. Post
    B

    bjng

    @bjng

    • Profilo
    • Chi segue 0
    • Da chi è seguito 0
    • Discussioni 1
    • Post 3
    • Migliore 0
    • Gruppi 0
    Iscrizione Ultimo Accesso
    Località Milano
    0
    Reputazione
    3
    Post
    0
    Visite al profilo
    0
    Da chi è seguito
    0
    Chi segue
    User Newbie

    Post creati da bjng

    • RE: Ciclo con cUrl

      Risolto, era da fare
      $url = trim($url); :wink3:
      grazie lo stesso
      ciao

      postato in Coding
      B
      bjng
    • RE: Recuperare dato da tabella relazionata

      Ciao

      select a.id,a.nome,a.descrizione,b.descrizione as categoria from oggetto a inner join categoria b on a.categoria = b.id

      CIao

      postato in Coding
      B
      bjng
    • Ciclo con cUrl

      Buongiorno a tutti.
      Sono nuovo del forum e anche del mondo PHP.

      Quello che devo fare è:
      leggere un file csv/txt fatto in questo modo:

      id||url
      1||miourl_1.html
      2||miourl_2.html

      e scrivere un altro file così:
      id||codice html delle pagine
      1||<html>codice url1</html>
      2||<html>codice url2</html>

      ho usato lo script seguente:

      <?php
      
      
      $myfile = fopen("sourcefile.txt", "r") or die("Unable to open file!");
      $writefile = fopen("destinationfile.txt","w")  or die("Unable to open file!");
      do {
          $buffer = fgets($myfile);
          $part1 = explode("||", $buffer);
          $url = $part1[1];
      
      
      
      
                  $options = array(
                      CURLOPT_RETURNTRANSFER => true,     // return web page
                      CURLOPT_HEADER         => false,    // don't return headers
                      CURLOPT_FOLLOWLOCATION => true,     // follow redirects
                      CURLOPT_ENCODING       => "",       // handle compressed
                      CURLOPT_USERAGENT      => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2", // who am i
                      CURLOPT_AUTOREFERER    => true,     // set referer on redirect
                      CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
                      CURLOPT_TIMEOUT        => 120,      // timeout on response
                      CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
                      );
              
                  $ch      = curl_init($url);
                  curl_setopt_array( $ch, $options );
                  $content = curl_exec( $ch );
                  $err     = curl_errno( $ch );
                  $errmsg  = curl_error( $ch );
                  $header  = curl_getinfo( $ch );
                  curl_close( $ch );
              
                  $header['errno']   = $err;
                  $header['errmsg']  = $errmsg;
                  $header['content'] = $content;
                  
                  fwrite($writefile, $part1[0] . "||" . preg_replace('~[[:cntrl:]]~', '', strip_tags($content,"<table><td><tr><b><strong>")));
      
      
      } while (!feof($myfile));
      fclose($writefile);
      fclose($myfile);
      ?>
      
      

      Se non ciclo e passo una url alla volta funziona, se lo faccio ciclare sul file di origine non scrive niente ma non dà neanche errore.
      Cosa sbaglio? :arrabbiato:

      Grazie a tutti.

      Ste

      postato in Coding
      B
      bjng