我想创建一个Scraper或spider,它可以抓取此代码中的数据并将数据插入数据库中:
<tr>
<td class="player-player-name">
<a href="/poker-players/14147-david-peat">David Peat</a>
</td>
<td><img alt="UNITED STATES" class="flag" src="/packages/flags/us-238691e8450c6bd68131f09bcf546d4a.png" title="UNITED STATES" /> Las Vegas, NV, USA</td>
<td>$277,047</td>
<td class="recent-cashes">
<a href="/poker-tournaments/876-2007-mirage-poker-showdown-wpt/7540" class="event-name-link" ref="nofollow">No-Limit Hold'em Championship Event 10</a>
</td>
</tr>
我还需要保存标志和下一页的链接。有大约20页的扑克玩家我需要在我的数据库中保存2016年扑克玩家和统计数据。
答案 0 :(得分:0)
像那样......
<?php
include('simple_html_dom.php');
$html = file_get_html('http://www.cardplayer.com/poker-players');
$theData = array();
foreach($html->find('.table-lined tr') as $row) {
$rowData = array();
foreach($row->find('td') as $cell) {
$rowData[] = $cell->innertext;
}
$theData[] = $rowData;
}
$length = count($theData);
for ($i = 1; $i < $length; $i++) {
echo "Player Name".$theData[$i][0]."----location".$theData[$i][1]."casino--".$theData[$i][2]."most".$theData[$i][3]."<br/>";
}
?>