Daten aus Internetseite auslesen

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #31
    Original geschrieben von Abraxax
    hast du auch mal $data verwendet?

    hier kannst du mit while das ganze durchlaufen und jeweils wieder ein explode machen nach doppelpunkt.

    diese infos schreibst du in ein neues MEHRDIMENSIONALES array rein.

    PHP Code:
    while (...) {
      
    $neuesarray[] = explode(":",$data[$arrayindex_von_data]);

    $arrayindex_von_data musst du dir sleber mal suchen.
    Sorry aber von mehrdimensionalen Arrays habe ich noch keine Ahnung und was soll in die While-Schleife, aber angeguckt habe ich mir $Data schon !!

    Comment


    • #32
      wo ist dein problem?

      wenn man $data verwendet, hat man auch kein problem mehr mit den tabellenüberbleibsel.

      Code:
      <?php
      
      $html = "<html><head><title>test</title></head><body>
      <center>
        <br>
      
        <table width=250>
          <tr>
            <th>16:152:5</th>
          </tr>
          <tr>
            <th>16:552:6</th>
          </tr>
          <tr>
            <th>6:52:75</th>
          </tr>
          <tr>
            <th>1:522:32</th>
          </tr>
          <tr>
            <th>36:522:12</th>
          </tr>
          <tr>
            <th>26:51:25</th>
          </tr>
        </table>
      </center></body></html>";
      
      // $fp = fopen ("DATEI", "r");
      // $html = fread($fp, 100000);
      // fclose($fp);
      
      $data = preg_grep("/(.*?)<th>([0-9]+:[0-9]+:[0-9]+)<\/th>(.*?)/is", explode("\n",$html));
      
      foreach ($data as $key => $value) {
          echo "Schlüssel: $key; Wert: $value<br>\n";
          $newdata[] = explode(":",trim($data[$key]));
      }
      
      echo "<pre>";
      print_r($newdata);
      echo "</pre>";
      
      ?>
      INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


      Comment


      • #33
        Original geschrieben von Murderdeath
        Sorry aber von mehrdimensionalen Arrays habe ich noch keine Ahnung und was soll in die While-Schleife, aber angeguckt habe ich mir $Data schon !!
        habs jetzt mit foreach gemacht. das geht besser ...
        INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


        Comment


        • #34
          habe jetzt noch die <th> und </th> gefilter. die standen noch drin.

          Code:
          <?php
          
          $html = "<html><head><title>test</title></head><body>
          <center>
            <br>
          
            <table width=250>
              <tr>
                <th>16:152:5</th>
              </tr>
              <tr>
                <th>16:552:6</th>
              </tr>
              <tr>
                <th>6:52:75</th>
              </tr>
              <tr>
                <th>1:522:32</th>
              </tr>
              <tr>
                <th>36:522:12</th>
              </tr>
              <tr>
                <th>26:51:25</th>
              </tr>
            </table>
          </center></body></html>";
          
          // $fp = fopen ("DATEI", "r");
          // $html = fread($fp, 100000);
          // fclose($fp);
          
          $data = preg_grep("/(.*?)<th>([0-9]+:[0-9]+:[0-9]+)<\/th>(.*?)/is", explode("\n",$html));
          
          foreach ($data as $key => $value) {
              echo "Schlüssel: $key; Wert: $value<br>\n";
              $newdata[] = explode(":",trim(str_replace("<th>","",str_replace("</th>","",$data[$key]))));
          }
          
          echo "<pre>";
          print_r($newdata);
          echo "</pre>";
          
          ?>
          INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


          Comment


          • #35
            PHP Code:
            Schlüssel6Wert16:152:
            Schlüssel
            9Wert16:552:
            Schlüssel
            12Wert6:52:75 
            Schlüssel
            15Wert1:522:32 
            Schlüssel
            18Wert36:522:12 
            Schlüssel
            21Wert26:51:25 

            Array
            (
                [
            0] => Array
                    (
                        [
            0] => 16
                        
            [1] => 152
                        
            [2] => 5
                    
            )

                [
            1] => Array
                    (
                        [
            0] => 16
                        
            [1] => 552
                        
            [2] => 6
                    
            )

                [
            2] => Array
                    (
                        [
            0] => 6
                        
            [1] => 52
                        
            [2] => 75
                    
            )

                [
            3] => Array
                    (
                        [
            0] => 1
                        
            [1] => 522
                        
            [2] => 32
                    
            )

                [
            4] => Array
                    (
                        [
            0] => 36
                        
            [1] => 522
                        
            [2] => 12
                    
            )

                [
            5] => Array
                    (
                        [
            0] => 26
                        
            [1] => 51
                        
            [2] => 25
                    
            )


            Das kommt bei mir raus.

            Allerdings möchte ich nur das:

            PHP Code:
            Array[0] = 16:152:
            Array[1] = 16:552:
            Array[2] = 6:52:75 
            Array[3] = 1:522:32 
            Array[4] = 36:522:12 
            Array[5] = 26:51:25 
            Noch komplizierte sieht das ganze aus wenn $html nicht eine Spalte enthält sondern mehrere die daten enthalten die ich aber gar nciht haben will !

            Comment


            • #36
              dann mache keinen weiteren explode

              PHP Code:
              // mit explode nach :
              $newdata[] = explode(":",trim(str_replace("<th>","",str_replace("</th>","",$data[$key]))));

              // OHNE explode nach :
              $newdata[] = trim(str_replace("<th>","",str_replace("</th>","",$data[$key]))); 
              INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


              Comment


              • #37
                Habe aber NOCH ein problem wenn $html so aussieht:

                PHP Code:
                <tr>
                <
                th>test2</th>
                <
                th>test2</th>
                <
                th>test3</th>
                </
                tr>
                <
                tr>
                <
                th>16:512:15</th>
                <
                th>test2</th>
                <
                th>test3</th>
                </
                tr>
                <
                tr>
                <
                th>16:552:56</th>
                <
                th>test2</th>
                <
                th>test3</th>
                </
                tr

                Comment


                • #38
                  und ich möchte ja nur die Zahlen haben den Rest nicht !!!

                  Comment


                  • #39
                    hab den Fehler gefunden. Der HTMl-Code von der Datei die mit fopen lade; dort wird alles hintereinander ausgegeben und nicht so wie es üblich ist mit Zeilenumbruch zur besseren Strukturrierung, und es klapp wenn ich den Code in Zeilenumbrüche umwandle dann tut das script seinen Dienst, anders herum allerdings nicht, aber kann ich das mit PHP umwandeln ?

                    Comment


                    • #40
                      habs schon selber gelöst durch:

                      PHP Code:
                      $html str_replace("><"">\n<"$html); 

                      Comment


                      • #41
                        Wie kann ich auslesen wieviele Werte das Array hat. ich will nämlich in ner While Schleife zudem wert html formatierungen ausgeben, aber dazu muss ich ja wissen wieviele Werte das Array hat !

                        Comment


                        • #42
                          schau mal hier...

                          http://www.php.net/manual/en/function.count.php

                          =)

                          du kannst das array auch mit foreach durchlaufen und schlüssel bzw. die dazugehörigen elemente zählen...

                          http://www.php.net/manual/en/control...es.foreach.php

                          alles ist möglich *g*

                          Comment


                          • #43
                            habs auch gefunden mit count gehts.

                            Comment


                            • #44
                              so bei meinem Projekt habe ich jetzt ein weiteres Problem:

                              Ich habe ein select feld. Wenn man dort etwas auswählt soll zu erst in einem Frame eine Seite geöffnet werden; das dabei aber auch noch in einer variabel gespeichert werden. Anschließend wird das hier ausgeführt:

                              PHP Code:
                              <SCRIPT language=JavaScript>
                              <!--
                              function cp(pl){
                              eval("parent.location='browser.php?id=<?PHP echo $id?>&p="+pl.options[pl.selectedIndex].value+"'");
                              }
                              // --></SCRIPT>
                              Bisher wird bei dem onchange ereigniss nur das obige script ausgeführt, aber ich möchte halt das vorher im Frame mit dem namen "x" eine Seite aufgerufen wird und das gepseichert wird !

                              Comment


                              • #45
                                ich würde auch frames verzichten und lieber einen include machen.
                                INFO: Erst suchen, dann posten![color=red] | [/color]MANUAL(s): PHP | MySQL | HTML/JS/CSS[color=red] | [/color]NICE: GNOME Do | TESTS: Gästebuch[color=red] | [/color]IM: Jabber.org |


                                Comment

                                Working...
                                X