Web crawling By Puppeteer @ Node.js - Part 2/2, How to make it work on Android?
Outlines
1. Install ubuntu on Android by AndroNix
2. Install node.js and puppeteer
3. start web crawling
4. advanced adjustments to display chinese characters
- Install Ubuntu on Android by the help of "AndroNix"
- Install the APP "Termux" and run "pkg update"
- Install the APP "AndroNix"
- Install the APP "VNC Viewer"
- Install Ubuntu 18 with XFCE (recommended):
Follow the instructions on AndroNix to copy a command to paste on Termux
- After installation, you'll be told to set a VNC password to connect to your system
- Start VNC Server by "vncserver-start", and stop it by "vncserver-stop"
- Now you can run "VNC Viewer" and add an address of "localhost:1"
- Shutdown your Ubuntu by "exit" in Termux and "Force close" Termux,
- Turn on Ubuntu again by "./start-ubuntu.sh" in Termux
- Install node.js by the command
apt install nodejs
- Unfortunately, the default Node.js version was 8 and didn't support Puppeteer
- Download the latest Node.js from https://nodejs.org/en/download/
Inside your VNC Viewer's chromium browser
I chose "Linux Binaries (ARM)" -> "ARMv8" for my Zenfone 5 (ZE620KL)
- *** The steps starting from now doesn't seem really right.
- *** I need a professional person to teach me!
- After downloading the archive, I copied "bin/node" to "/usr/bin"
cp /path/to/archive/bin/node /usr/bin
to override the original node executable
- Then I created a folder under "/path/to/archive/bin" named as "node_crawler"
and changed the working folder to it: cd /path/to/archive/bin/node_crawler
- I ran "../npm install puppeteer"
- Then I created the example_code.js as shown in the previous part under node_crawler
- NOW HERE IS THE BIG POINT: I failed initially kept being notified: no-sandbox...
- Later I found the solution of changing the line that launches the browser to this:
const browser = await puppeteer.launch({
headless:false,
args:[ "--no-sandbox", "--disable-setuid-sandbox" ]
});
- I finally succeeded in running puppeteer on Android
- Chinese characters not showing in Chromium Browser
- Install Chinese Fonts (both Simplified & Traditional)
- Serif:
fonts-arphic-ukai
- Sans-serif:
fonts-arphic-uming
- apt install fonts-arphic-ukai
- apt install fonts-arphic-uming
- Want to switch system language to Chinese?
- apt install language-pack-zh*
- apt install chinese*
- apt install locales
- Edit
/etc/default/locale
and set the contents to:
- LANG="zh_TW.UTF-8"
- Edit
/etc/locale.gen
and uncomment the lines for the locales that you want to enable
- Then, run locale-gen to generate the locale
- Create a new user and login to it
- Before adding a new user, run "vncserver-stop"
- adduser User_Name
- su - User_Name
- Logout by "exit" to return to root
- run "vncserver-start" under the User_Name
- Then, access Ubuntu using VNC Viewer, and now its system language is Chinese
沒有留言:
張貼留言