Laravel Türkiye Discord Kanalı Forumda kod paylaşılırken dikkat edilmesi gerekenler!Birlikte proje geliştirmek ister misiniz?
  • YardımLaravel
  • Laravel projesinde .onion sitesinden ekran görüntüsü alma

  • eday

      Seviye 4

    Laravel projesinde .onion sitesinden ekran görüntüsü almaya çalışıyorum fakat hata alıyorum. Tor browserım açık halde.

            Browsershot::url($url)
                ->waitForSelector($selector, ['timeout' => 60000]) // 1 dakika bekle
                ->setOption('proxy-server', 'socks5://127.0.0.1:9150')
                ->screenshot($path);
        } catch (\Exception $e) {
            $this->error("Screenshot alırken hata oluştu: " . $e->getMessage());
        }

    Hata mesajım:
    Screenshot alırken hata oluştu: The command ""C:\Program Files\nodejs\node.EXE" C:\Users\nopi\Desktop\scraper\vendor\spatie\browsershot\src/../bin/browser.cjs "{""url"":""http:\/\/darkobds5j7xpsncsexzwhzaotyc4sshuiby3wtxslq5jy2mhrulnzad.onion\/darkzone-forum\/forum\/darkzone-forum-community\/"",""action"":""screenshot"",""options"":{""type"":""png"",""args"":[],""viewport"":{""width"":800,""height"":600},""waitForSelector"":""div.content-element:nth-child(1) > div:nth-child(2)"",""waitForSelectorOptions"":{""timeout"":60000},""proxy-server"":""127.0.0.1:9150""}}"" failed.

    • koti42

        Seviye 246

      Browsershot, Chromium tabanlı bir tarayıcı kullanarak çalışır ve bu tarayıcı .onion sitelerine doğrudan erişemez. Bunun için aşağıdaki gibi bir yapı kullanabilirsiniz:

      Tor üzerinden Chromium çalıştırma: Tor ile entegre çalışan bir headless Chromium kullanmanız gerekiyor. Bunun için

      --proxy-server=socks5://127.0.0.1:9150 argümanını doğrudan puppeteer veya Browsershot'a iletmelisiniz:

      Browsershot::url($url)
          ->addChromiumArguments(['--proxy-server=socks5://127.0.0.1:9150'])
          ->waitForSelector($selector, ['timeout' => 60000])
          ->screenshot($path);
      • eday

          Seviye 4
        • Düzenlendi

        teşekkür ederim sitenin içeriğe erişebiliyorum fakat ekran resmini bulamıyor. resim dosyalarıma gelmiyor

        <?php

        namespace App\Console\Commands;

        use Illuminate\Support\Facades\Storage;
        use Illuminate\Console\Command;
        use Spatie\Browsershot\Browsershot;

        class CaptureScreenshots extends Command
        {
        protected $signature = 'capture:screenshots';
        protected $description = 'Capture screenshots of websites with Tor proxy';

        public function handle()
        {
            $url = 'https://check.torproject.org';
            $filename = uniqid() . '.png';
            $screenshotPath = storage_path('app/public/screenshots/');
            $proxy = 'socks5://127.0.0.1:9050';
        
            try {
                Browsershot::url($url)
                    ->setOption('args', ['--proxy-server=' . $proxy, '--location'])
                    ->waitForSelector('title', ['timeout' => 60000])
                    ->screenshot($screenshotPath . $filename);
        
                $pageTitle = Browsershot::url($url)
                    ->setOption('args', ['--proxy-server=' . $proxy, '--location'])
                    ->evaluate('document.title');
        
                $this->info('Page Title: ' . $pageTitle);
        
                if (Storage::disk('public')->exists('screenshots/' . $filename)) {
                    Storage::disk('public')->put('screenshots/' . $filename, file_get_contents($screenshotPath . $filename));
                    unlink($screenshotPath . $filename);
                    $this->info('Screenshot saved as: screenshots/' . $filename);
                } else {
                    $this->error('Screenshot not found at ' . $screenshotPath . $filename);
                }
            } catch (\Exception $e) {
                $this->error('Error: ' . $e->getMessage());
            }
        }

        }

        **PS C:\Users\nopi\Desktop\scraper> php artisan capture:screenshots

        Page Title: Congratulations. This browser is configured to use Tor.
        Screenshot not found at C:\Users\nopi\Desktop\scraper\storage\app/public/screenshots/677e684dde271.png
        PS C:\Users\nopi\Desktop\scraper>**

        • koti42

            Seviye 246

          Biraz araştırma yapma fırsatım oldu.

          Öğrendiğim kadarıyla spatienin bu paketi destek sağlamıyor onion uzantili web sitelerine bu yüzden ekran resmini alamıyorsunuz diye düşünüyorum.

          Saf php ile alınabilir mi emin degilim ama denenebilir Tor browser geliştirici kitini incelemek lazım.