geoRp的个人博客分享 http://blog.sciencenet.cn/u/geoRp

博文

R爬虫获取IPC分类号

已有 2327 次阅读 2019-5-30 11:34 |个人分类:R编程|系统分类:科研笔记| ipc

运用R语言获取四层ipc编码及分类

下边是结果示例,不想自己跑一遍的话可以留言获取全部

分类号sample.txt



base='http://www.soopat.com'

bu=c('A','B','C','D','E','F','G','H')

allxnt=data.frame()

for(b in 7:8){

  ipc=read_html(paste0('http://www.soopat.com/IPC/Parent/',bu[b]))

  Tables=ipc%>%html_nodes('table')

  erjis=Tables[1]%>%html_nodes('.IPCChild')%>%html_nodes('a')%>%html_attr('href')

  for(e in 12:length(erjis)){

    sipc=read_html(paste0(base,erjis[e]))

    STables=sipc%>%html_nodes('table')

    sanjis=STables[1]%>%html_nodes('.IPCChild')%>%html_nodes('a')%>%html_attr('href')

    for(s in 1:length(sanjis)){

      fouripc=read_html(paste0(base,sanjis[s])

      FTables=fouripc%>%html_nodes('table')

      fours=FTables[1]%>%html_nodes('.IPCChild')%>%html_nodes('a')%>%html_attr('href')

 foursshuoming=FTables[1]%>%html_nodes('.IPCContentRow')%>%html_nodes('.IPCContent')%>%html_nodes('a')%>%html_text()

      allxnt= rbind(allxnt,cbind(fours,foursshuoming) ) 

      print(c(b,e,s))

    }

    Sys.sleep(2)

  }

}




https://blog.sciencenet.cn/blog-3343669-1182023.html

上一篇:全国各省邮编前两位
下一篇:皖江城市带创新产出增长迅速
收藏 IP: 221.176.159.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (1 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-29 03:10

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部