Có một hướng dẫn Greate here kết hợp guzzlehttp và symfony/dom-crawler
Trong trường hợp liên kết bị mất ở đây là mã bạn có thể tận dụng.
use Guzzle\Http\Client;
use Symfony\Component\DomCrawler\Crawler;
use RuntimeException;
// create http client instance
$client = new GuzzleHttp\ClientClient('http://download.cloud.com/releases');
// create a request
$response = $client->request('/3.0.6/api_3.0.6/TOC_Domain_Admin.html');
// get status code
$status = $response->getStatusCode();
// this is the response body from the requested page (usually html)
//$result = $response->getBody();
// crate crawler instance from body HTML code
$crawler = new Crawler($response->getBody(true));
// apply css selector filter
$filter = $crawler->filter('div.apismallbullet_box');
$result = array();
if (iterator_count($filter) > 1) {
// iterate over filter results
foreach ($filter as $i => $content) {
// create crawler instance for result
$cralwer = new Crawler($content);
// extract the values needed
$result[$i] = array(
'topic' => $crawler->filter('h5')->text();
'className' => trim(str_replace(' ', '', $result[$i]['topic'])) . 'Client'
);
}
} else {
throw new RuntimeException('Got empty result processing the dataset!');
}
Nguồn
2017-01-03 05:30:00
Không có trình thu thập dữ liệu nào sẽ thực hiện việc cạo dữ liệu, đó là điều bạn sẽ phải tự viết. Và cũng đảm bảo những gì bạn đang nâng không có bản quyền. –
có thể trùng lặp của [Phương pháp tốt nhất để phân tích cú pháp HTML] (http://stackoverflow.com/questions/3577641/best-methods-to-parse-html/3577662#3577662) – Gordon
bản sao bổ sung có thể trong http://stackoverflow.com q = web + trình thu thập thông tin + php – Gordon