· 6 years ago · Jul 22, 2019, 04:26 PM
1https://www.sahibinden.com/kiralik/istanbul-adalar-burgazada?pagingSize=50<?php
2
3namespace App\Console\Commands;
4
5use App\SourceUrl;
6use Illuminate\Console\Command;
7use Dapphp\TorUtils\ControlClient;
8
9class ImportAdLinks extends Command
10{
11 /**
12 * The name and signature of the console command.
13 *
14 * @var string
15 */
16 protected $signature = 'import:adlinks';
17
18 /**
19 * The console command description.
20 *
21 * @var string
22 */
23 protected $description = 'Command description';
24
25 /**
26 * Create a new command instance.
27 *
28 * @return void
29 */
30 public function __construct()
31 {
32 parent::__construct();
33 }
34
35 /**
36 * Execute the console command.
37 *
38 * @return mixed
39 */
40 public function handle()
41 {
42
43 $tc = new ControlClient();
44
45 try {
46 $tc->setDebug(true);
47 $tc->connect('172.17.0.3:9051'); // connect to 172.17.0.2:9051
48 $tc->authenticate('test'); // can also use cookie or empty auth
49 $tc->signal(ControlClient::SIGNAL_NEWNYM);
50 echo "Signal sent - IP changed successfully!\n";
51 } catch (\Exception $ex) {
52 echo "Signal failed: " . $ex->getMessage() . "\n";
53 }
54
55 $phpPuppeteer = new \PhpPupeeteer\PhpPupeeteer;
56
57
58 // try {
59
60 $browser = $phpPuppeteer->connect([
61 'browserWSEndpoint' => 'ws://127.0.0.1:3000?--proxy-server=http://172.17.0.3:8118&--no-sandbox',
62
63 'ignoreHTTPSErrors' => true,
64 'defaultViewport' => [
65 'width' => 1920,
66 'height' => 1024,
67 'isMobile' => false,
68 ],
69 'userAgent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
70 //'headless' => false,
71
72 'idle_timeout' => 0,
73 'read_timeout' => 300,
74 'args' => [
75 '--no-sandbox',
76 '--disable-setuid-sandbox',
77 '--disable-dev-shm-usage',
78 '--disable-gpu',
79 '--proxy-server=http://172.17.0.3:8118', // proxy
80 // '--0', // disable timing information for chrome://profiler
81
82
83 ],
84 ]);
85
86
87 $page = $browser->createIncognitoBrowserContext()->newPage()
88 ->disableRequestsByTypes([
89 'image',
90 'media',
91 'font',
92 'texttrack',
93 'object',
94 'beacon',
95 'csp_report',
96 'imageset',
97 ])
98 ->disableRequestsByDomains([
99 'google-analytics.com',
100 'googletagservices.com',
101 'doubleclick.net',
102 'google.com',
103 'google.ru',
104 //'yandex.ru',
105 'facebook.net',
106 'facebook.com',
107 'twitter.com',
108 'tns-counter.ru',
109 'vk.com',
110 'yadro.ru',
111 ]);
112
113 $info = SourceUrl::all()->first();
114// dump($info->url);
115 $page->gotoWithWait($info->url);
116// $page->gotoWithWait('https://2ip.ru/');
117 // $data = $page->content();
118 $page->screenshot(['path' => storage_path("screens/{$info->id}.png")]);
119
120
121
122// dump($data);
123
124// } catch (\Throwable $throwable) {
125// echo '[!] ERROR: ' . $throwable->getMessage() . ' in ' . $throwable->getFile() . ':' . $throwable->getLine() . PHP_EOL;
126// }
127
128 }
129}