Install ChromeDriver and Fonts

Prepare for install
yum -y install libX11 GConf2 fontconfig
[root@localhost test]# wget https://chromedriver.storage.googleapis.com/73.0.3683.68/chromedriver_linux64.zip
–2019-05-24 09:20:33– https://chromedriver.storage.googleapis.com/73.0.3683.68/chromedriver_linux64.zip
chromedriver.storage.googleapis.com をDNSに問いあわせています… 216.58.197.208, 2404:6800:4004:80e::2010
chromedriver.storage.googleapis.com|216.58.197.208|:443 に接続しています… 接続しました。
HTTP による接続要求を送信しました、応答を待っています… 200 OK
長さ: 5008482 (4.8M) [application/zip]
`chromedriver_linux64.zip’ に保存中

100%[======================================>] 5,008,482 1.67M/s 時間 2.9s

2019-05-24 09:20:36 (1.67 MB/s) – `chromedriver_linux64.zip’ へ保存完了 [5008482/5008482]

[root@localhost test]# ls
chromeTest.js chromedriver_linux64.zip index.php node_modules selenium-test
[root@localhost test]# unzip chromedriver_linux64.zip
Archive: chromedriver_linux64.zip
inflating: chromedriver
[root@localhost test]# mv chromedriver /usr/local/bin/
[root@localhost test]# chmod 755 /usr/local/bin/chromedriver

install selenium

$ npm -g install selenium-webdriver
$ npm install selenium-webdriver

https://sites.google.com/a/chromium.org/chromedriver/downloads

sudo yum install -y google-chrome-unstable libOSMesa google-noto-cjk-fonts

var webdrive = require('selenium-webdriver');
var driver;
var By = webdriver.By;

driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.chrome())
.build();

driver.get('https://www.google.co.jp/').then(function(){
	driver.findElement(By.id('hplog')).click()
	.then(function(){
		console.log('clicked logo');
	});
});

[vagrant@localhost test]$ node chromeTest.js

/home/vagrant/local/app/test/node_modules/selenium-webdriver/index.js:25
const _http = require(‘./http’);
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/vagrant/local/app/test/chromeTest.js:1:78)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)

About PhantomJS

WebKit based headless browser.
Webkit is a rendering engine mainly used in web browsers. PhantomJS uses a JavaScript engine called JavaScriptCore (which also uses safari) which is built-in Web-kit.

An environment in which a browser can be executed by commands programs.
Because the program can control the movement, PhantomJS is good at
– Automation test
– Scraping

In automated testing, Selenium + PhantomJS often come out as a set.

phantomjs

cd /usr/local/src/
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar jxf phantomjs-2.1.1-linux-x86_64.tar.bz2
cp phantomjs-2.1.1-linux-x86_64/bin/phantomjs /usr/bin/

[vagrant@localhost src]$ phantomjs –version
2.1.1

from selenium import webdriver
url = "http://www.aozora.gr.jp/cards/000081/files/46268_23911.html"

browser = webdriver.PhantomJS()
browser.implicitly_wait(3)
browser.get(url)
browser.save_screenshot("Website.png")
browser.quite()

[vagrant@localhost python]$ python3 app.py
/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/selenium/webdriver/phantomjs/webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
warnings.warn(‘Selenium support for PhantomJS has been deprecated, please use headless ‘
Traceback (most recent call last):
File “app.py”, line 8, in
browser.quite()
AttributeError: ‘WebDriver’ object has no attribute ‘quite’

from selenium import webdriver
url = "http://www.aozora.gr.jp/cards/000081/files/46268_23911.html"

browser = webdriver.PhantomJS()
browser.implicitly_wait(3)
browser.get(url)
browser.save_screenshot("Website.png")
browser.quit()

[vagrant@localhost python]$ python3 app.py
/home/vagrant/.pyenv/versions/3.5.2/lib/python3.5/site-packages/selenium/webdriver/phantomjs/webdriver.py:49: UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead
warnings.warn(‘Selenium support for PhantomJS has been deprecated, please use headless ‘

[vagrant@localhost src]$ cat /etc/fonts/conf.d/51-local.conf




local.conf

[vagrant@localhost src]$ cat /etc/fonts/fonts.conf



/usr/share/fonts
/usr/share/X11/fonts/Type1 /usr/share/X11/fonts/TTF /usr/local/share/fonts
~/.fonts




mono


monospace




sans serif


sans-serif




sans


sans-serif


conf.d

/var/cache/fontconfig
~/.fontconfig




0x0020
0x00A0
0x00AD
0x034F
0x0600
0x0601
0x0602
0x0603
0x06DD
0x070F
0x115F
0x1160
0x1680
0x17B4
0x17B5
0x180E
0x2000
0x2001
0x2002
0x2003
0x2004
0x2005
0x2006
0x2007
0x2008
0x2009
0x200A
0x200B
0x200C
0x200D
0x200E
0x200F
0x2028
0x2029
0x202A
0x202B
0x202C
0x202D
0x202E
0x202F
0x205F
0x2060
0x2061
0x2062
0x2063
0x206A
0x206B
0x206C
0x206D
0x206E
0x206F
0x2800
0x3000
0x3164
0xFEFF
0xFFA0
0xFFF9
0xFFFA
0xFFFB



30

mono, sans, san-serifがあるのはわかったが、migmixを入れろってか。