2

I am using Symfony Panther for web scraping (not testing) in a PHP project that does not use Symfony. I installed via Composer. Each time I need to scrape a link submitted by a user, I start a new Chrome Browser.

$client = Symfony\Component\Panther\Client::createChromeClient('/usr/bin/chromedriver');
$client->request('GET', $url);
$crawler = $client->waitFor('body');

Starting a new Chrome browser for each submitted $url is slow and resource intensive, so I want to keep the Chrome Client running on port 9515 and then each user's $url request can connect to that one same instance. Based on some user comments on Github, it sounds like a reasonable method:

  • Spin up a Chrome instance on the Linux server, running on port 9515
  • Make each url request connect to that instance.

I placed the first line i.e. with createChromeClient in a php script for a CRON job, but it never starts up the chrome client, and I get no errors either. Any ideas how to achieve this?

Cogicero
  • 1,514
  • 2
  • 17
  • 36

2 Answers2

0

"Not showing" the browser (Chrome here) is the default way, as it is faster. It is called "headless"

To show it, you have to specify "PANTHER_NO_HEADLESS" :

PANTHER_NO_HEADLESS=1 vendor/bin/phpunit -c phpunit.xml

also, you could check if chome is running with : (or any system log)

ps aux | grep chrome
bloub
  • 101
  • 1
  • 3
0

@Cogicero You set this option in phpunit.xml.dist file :

<env name="PANTHER_NO_HEADLESS" value="1" />

And comment it if u don't want to see the browser.