2016-04-16 10 views
0

Die Website, die ich kratzen muss eine Tabelle mit der gleichen Zeile auf allen Seiten. Mit dem online gefundenen Code kann ich nur die erste Zeile abkratzen.Wie scrape alle div auf allen Seiten einer Webseite

<table class="players"> 
      <tr><th><a href="./?sort=pos&amp;order=a" rel="nofollow">Position</a></th><th><a href="./?sort=name&amp;order=a" rel="nofollow">Player Name</a></th><th><a href="./?sort=club_team&amp;order=a" rel="nofollow">Team Name</a></th><th><a href="./?sort=nationality&amp;order=a" rel="nofollow">Nationality</a></th><th><a href="./?sort=height" rel="nofollow">Height</a></th><th><a href="./?sort=weight" rel="nofollow">Weight</a></th><th><a href="./?sort=age&amp;order=a" rel="nofollow">Age</a></th><th><a href="./?sort=condition" rel="nofollow">Condition</a></th><th class=" selected"><a href="./?order=a" rel="nofollow">Overall Rating</a></th></tr> 
      <tr><td class="posFW"><div title="Second Striker">SS</div></td><td class="left"><a href="./?id=7511">L. MESSI</a></td><td class="left"><a href="./?all=1&amp;club_team=%22FC BARCELONA%22&amp;sort=club_number&amp;order=a" rel="nofollow">FC BARCELONA</a></td><td class="left"><a href="./?nationality=%22ARGENTINA%22&amp;sort=national_number&amp;order=a" rel="nofollow">ARGENTINA</a></td><td>170</td><td>72</td><td>28</td><td class="condition"><img src="images/condition2.png" alt="2" /></td><td class="selected c3 lvl30">94</td></tr> 

Mein Code:

<?php 
$uri = 'http://myoldsite.net/data/';  
$get = file_get_contents($uri); 
$pos1 = strpos($get, "<div title="); 
$pos2 = strpos($get, "</div>", $pos1); 
$text = substr($get,$pos1,$pos2-$pos1+3); 
echo $text; 
?> 

ich kratzen müssen: Position, Spieler Name, Alter und Insgesamt kann ich nur erster div = "Titel ... wie mit meinem Code kratzt alle kratzen in allen Seiten Reihen ...

Antwort

Verwandte Themen