我想制作一个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年的扑克玩家和统计数据中。
那样的东西.....
<?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/>";
}
?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句