[置顶] 【R语言爬虫】R语言提交get请求抓取城城理财数据
2017-05-26 17:43
441 查看
一、需求分析
抓取城城理财数据。
抓取url:
https://www.cclc.co/debts/lctz_all_all
二、实现源代码
抓取城城理财数据。
抓取url:
https://www.cclc.co/debts/lctz_all_all
二、实现源代码
rm(list=ls()) library(XML) library(RCurl) url='https://www.cclc.co/debts/lctz_all_all' myheader <- c( "User-Agent"="Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.97 Safari/537.36", "Accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Accept-Language"="gzip, deflate, sdch", "Connection"="keep-alive", "Accept-Charset"="GB2312,utf-8;q=0.7,*;q=0.7" ) d <- debugGatherer() web <- getURL(url, httpheader = myheader, debugfunction = d$update, verbose = T,ssl.verifyhost=FALSE,ssl.verifypeer=FALSE) url_list="" i=1:3 url_list[i]=paste0('https://www.cclc.co/debts/lctz_all_all_',i+1) for(k in url_list){ web1 <-getURL(k, httpheader = myheader, debugfunction = d$update, verbose = T,ssl.verifyhost=FALSE,ssl.verifypeer=FALSE) web<-c(web,web1) } doc<-htmlParse(web,encoding = "UTF-8") project_title<-sapply(getNodeSet(doc,"//h2[@class='title']//a"),xmlValue) project_rate<-sapply(getNodeSet(doc,"//span[@class='main_top_num']"),xmlValue) project_day<-sapply(getNodeSet(doc,"//div[@class='datar fl']//p"),xmlValue) kk=length(project_day) project_money_start<-sapply(getNodeSet(doc,"//div[@class='progress-top']//span"),xmlValue) target_time<-Sys.Date() project<-data.frame(project_title=project_title[1:kk],project_rate=project_rate[1:kk],project_day=project_day[1:kk],target_time) project$platform<-c("城城理财") View(project) ##################模糊匹配处理天数################ a101<-grep("个月",project[,3]) a102<-project[a101,] a102[,3]<-gsub("个月","",a102[,3]) a102[,3]<-as.numeric(a102[,3])*30 a201<-grep("天",project[,3]) a202<-project[a201,] a202[,3]<-gsub("天","",a202[,3]) a301<-rbind(a102,a202) a301[,3]<-as.numeric(a301[,3]) View(a301)
相关文章推荐
- [置顶] 【R语言爬虫】R语言提交post请求抓取盈盈理财数据
- [置顶] 【R语言爬虫】网贷天眼数据平台表格数据抓取2
- [置顶] python语言处理get类型请求,调试模式获取数据代码
- Android 通过Get/Post提交请求数据到服务器
- [置顶] 【R语言爬虫】网贷天眼平台表格数据爬虫1
- 安卓基础-get post请求与提交数据
- Android传统HTTP请求get----post方式提交数据(包括乱码问题)
- 数据抓取中post与get方式的处理深入理解(不用给网页标签赋值也不用模拟提交js)
- android利用httpclient实现post、get请求restful接口进行json和form表单数据提交等公共方法类
- [置顶] [爬虫]使用python抓取京东全站数据(商品,店铺,分类,评论)
- 表单提交数据get请求和post请求的区别
- Android传统HTTP请求get----post方式提交数据(包含乱码问题)
- HttpUrlConnection两种请求数据的方式get和post提交数据
- 表单提交数据get请求和post请求的区别?
- [置顶] 【python爬虫】网贷天眼平台表格数据抓取
- 表单提交数据get请求和post请求的区别
- PHP发送POST请求的三种方式 分别使用curl file_get_content fsocket 来实现post提交数据
- 表单提交数据请求 get和post的 区别
- form表单提交数据get,post请求的区别
- 表单提交数据get请求和post请求的区别