«   2018/07   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Archives
Today
31
Total
1,123,200
안정적인 DNS서비스 DNSEver
관리 메뉴

Blue Breeze

Simple PHP Web Scraper Guotte 본문

Language/PHP

Simple PHP Web Scraper Guotte

푸른바람 C/H 2018.06.29 08:30

Goutte, a simple PHP Web Scraper

구트(Goutte), 심플 PHP 웹 스크레이퍼

Installation

composer require fabpot/goutte

Usage

require_once "vendor/autoload.php";

use Goutte\Client;

$client = new Client();
$crawler = $client->request('get', "http://www.symfony.com/blog/");

$crawler->filter('title')->each(function($node){
    echo $node->text()."\n";
});

Results

The Symfony Blog

Usage2

require_once "vendor/autoload.php";

use Goutte\Client;
use GuzzleHttp\Client as GuzzleClient;

$client = new Client();
$guzzle = new GuzzleClient([
    'timeout' => 60,    // 60초 요청제한
]);
$client->setClient($guzzle);

$crawler = $client->request('GET', 'https://www.symfony.com/blog/');
$crawler->filter('title')->each(function($node){
    echo $node->text()."\n";
});

// Click on the "Security Advisories" link, 클릭
$link = $crawler->selectLink('Security Advisories')->link();
$crawler = $client->click($link);

$crawler->filter('title')->each(function($node){
    echo $node->text()."\n";
});

Results

The Symfony Blog
Security Advisories posts on the Symfony blog


'Language > PHP' 카테고리의 다른 글

PHP Goutte Cookie  (0) 2018.07.01
PHP Guzzle Scraper  (0) 2018.06.30
Simple PHP Web Scraper Guotte  (0) 2018.06.29
Python Scrapy 사이트 스크랩/크롤링  (0) 2018.06.28
PHP Laravel Framework helloWorld  (0) 2018.06.15
PHP reactPHP helloWorld  (0) 2018.06.14
0 Comments
댓글쓰기 폼