-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.php
More file actions
40 lines (30 loc) · 1.14 KB
/
start.php
File metadata and controls
40 lines (30 loc) · 1.14 KB
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
32
33
34
35
36
37
38
39
<?php
require_once( 'vendor/autoload.php' );
// The configs should be in the .env file
Config::load();
// The Goutte scrapper
$client = new Goutte\Client();
$base_uri = 'http://goodwilldelivery.ge/category.aspx?id=6';
$crawler = $client->request( 'GET', $base_uri );
$link = $crawler->selectLink( 'მზა კვება' )->link();
$pcrawler = $client->click( $link );
// Logging and DB
$log = Logger::get( 'scrapper' );
$db = Db::get( );
$stm = $db->prepare( 'SHOW TABLES' );
$stm->execute( );
$log->debug( 'The SHOW TABLES are these: ', $stm->fetchAll() );
$pcrawler->filter( "#ProductMenu > a " )->each( function( $a ) use ( $log ) {
$thing = sprintf( "%s -> %s\n", $a->text(), $a->attr('href') );
$log->debug( 'The DEBUG message!', ( is_array( $thing ) ? $thing : [ $thing ] ) );
});
// GuzzleHttp and phpQuery version
$client = new GuzzleHttp\Client([ 'base_uri' => $base_uri ]);
$resp = $client->get( '/category.aspx?id=6' );
$html = phpQuery::newDocument( $resp->getBody() );
$things = $html->find( '#ProductMenu > a' );
foreach( $things as $a )
{
$a = pq( $a );
printf( "%s -> %s\n", $a->text(),$a->attr( 'href' ) );
}