环境:
一台旧安卓机cpu 4核 armhf 内存2G互联网安装流程
将安卓手机root (必须)
去应用商店下载app linux deploy 应用,安装
打开后,在右下角点击下载应用配置:
发行版 : ubuntu
架构: armhf源地址: 如果网速好可以选择默认源,如果网速差建议去百度清华源或者网易源安装路径要选好;镜像大小: 选择2048M 用户名自定义密码自定义勾选允许启动SSH服务 (默认端口22)不勾选允许图形界面启动
在depoly界面右上角选择安装,然后等待下载成功;
成功后选择启动系统,此时界面上有系统的局域网ip地址;
比如192.168.1.10
在PC端使用ssh工具,比如xshell远程连接设备(需要在同一个局域网下面)
登录ssh 192.168.1.10
登录后先安装aptitude,然后安装vim编辑器
sudo apt-get install aptitude sudo aptitude install vim
备份源文件并修改源列表,注意,该系统的源文件应该是基于armhf架构的
cp /etc/apt/sources.list source.list.bak
然后修改源列表,此处我们选择清华的源:
vim /etc/apt/soures.list#填入以下内容:deb http://mirrors./ubuntu-ports/ xenial main multiverse restricted universedeb http://mirrors./ubuntu-ports/ xenial-backports main multiverse restricted universedeb http://mirrors./ubuntu-ports/ xenial-proposed main multiverse restricted universedeb http://mirrors./ubuntu-ports/ xenial-security main multiverse restricted universedeb http://mirrors./ubuntu-ports/ xenial-updates main multiverse restricted universedeb-src http://mirrors./ubuntu-ports/ xenial main multiverse restricted universedeb-src http://mirrors./ubuntu-ports/ xenial-backports main multiverse restricted universedeb-src http://mirrors./ubuntu-ports/ xenial-proposed main multiverse restricted universedeb-src http://mirrors./ubuntu-ports/ xenial-security main multiverse restricted universedeb-src http://mirrors./ubuntu-ports/ xenial-updates main multiverse restricted universe
完成后更新源列表:
sudo apt-get update
vim 中文输入乱码解决:
#安装localesaptitude install locales#配置localesdpkg-reconfigure locales#选择以下几种编码
en_US.UTF8
zh_CN GB2312
zh_CN GBK GBK
zh_CN UTF-8 UTF-8
默认编码选择
zh_CN UTF-8 UTF-8
Generating locales (this might take a while)…
en_US.UTF-8… done
zh_CN.GB2312… done
zh_CN.GBK… done
zh_CN.UTF-8… done
Generation complete.
直接在线安装R语言
sudo aptitude install r-base
安装一些数据ETL的R包
install.packages(c("dplyr","stringr","data.table"),repos = "/CRAN/")#install.packages("dplyr",repos = "/CRAN/")
安装jdk8
sudo aptitude install openjdk-8-jdksudo aptitude install default-jre#重新配置R语言java环境变量sudo R CMD javareconf
安装curl linux包
sudo apt-get install libcurl4-openssl-devsudo apt-get install libxml2-dev
安装R爬虫包
install.packages(c("RCurl","XML"),repos = "/CRAN/")
R爬虫包测试代码:
library(stringr)library(RCurl)library(XML)url <- paste("/top250?start=",seq(0,225,by=25),"&filter=",sep = "")y <- NULL;country <- NULLfor (i in 1:length(url)){wp<-getURL(url[i],.encoding="gb2312",followlocation=T) doc <- htmlParse(wp,asText=T,encoding="UTF-8")#解析#电影名字name <- xpathSApply(doc,path="//span[@class='title'][1]",xmlValue)#评分score <- xpathSApply(doc,path="//span[@class='rating_num' and @property='v:average']",xmlValue)#上映时间time <- str_extract(xpathSApply(doc,path="//div[@class='bd']/p[@class='']",xmlValue),pattern = '[1-2][0-9]{3}')#生产地区for(j in 1:25){country[j] <- str_split(str_extract(xpathSApply(doc,path="//div[@class='bd']/p[@class='']",xmlValue),pattern = '[1-2][0-9].*/.*/'),pattern = "/")[[j]][2]}country <- str_trim(country)x <- cbind(name,score,time,country)y <- rbind(y,x)}y <- as.data.frame(y)#存入数据框y