Phantomjs with R

两盒软妹~` 提交于 2019-12-11 07:15:49

问题


I am trying to scrape data from a web page. Since the page has a dynamic content, I used phantomjs to handle. But, with the codes I am using, I just can download the data seen on the web page. However, I need to input the date range and then submit to get all the data I want.

Here are the codes i used,

library(xml2)
library(rvest)

connection <- "pr.js"  

writeLines(sprintf("var page=require('webpage').create();
var fs = require('fs');
    page.open('%s',function(){
    console.log(page.content);//page source;
    fs.write('pr.html', page.content, 'w');
    phantom.exit();
    });",url),con=connection)

system_input <- paste(path,"phantomjs"," ",connection,sep="")

system(system_input)

Thanks to the codes, I have the html output of the webpage which has been created dynamically.

And as I stated, I also need a date input submit. But I couldn't achieve.

The url is : https://seffaflik.epias.com.tr/transparency/piyasalar/gop/ptf.xhtml

来源:https://stackoverflow.com/questions/45014984/phantomjs-with-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!