Как очистить таблицы с https-сайтов с помощью R

Я хочу парсить таблицы с сайта с https. Мне нужны таблицы, которые касаются деталей будущего контракта (контракт, срок действия, размер лота, цена, маржа NRML, маржа IS)

Я написал этот код для получения таблиц с этого сайта, но он показывает две ошибки.

1) Ошибка в функции (тип, msg, asError = TRUE): Не удалось подключиться к нулевому порту 80: Соединение отклонено

2) Предупреждающее сообщение: содержимое XML не похоже на XML: 'https://zerodha.com/margin-calculator/Futures/'

library(XML)
library(RCurl)
zero='https://zerodha.com/margin-calculator/Futures/'
zero<-getURL("zero")
#Error in function (type, msg, asError = TRUE)  : 
#  Failed to connect to zero port 80: Connection refused
zero.table=readHTMLTable(zero)
#Warning message:
#XML content does not seem to be XML: 'https://zerodha.com/margin-calculator/Futures/' 

person Malko    schedule 16.02.2016    source источник


Ответы (1)


я бы использовал httr

library("httr")
library("rvest")
zero <- httr::GET("https://zerodha.com/margin-calculator/Futures/zero")
tables <- rvest::html_table(content(zero))
head(tables[[1]])

Product type                       Name
    1         NRML                     Normal
    2          MIS Margin Intraday Square off
    3           CO                Cover Order
                                                                                                                                                                                                                      Used for
    1 Overnight/positional or intraday trade futures using NRML with margins mentioned below. Once a position taken as NRML, it can be held till the expiry provided the requesite NRML margin present in the trading account.
    2                                                                    Intraday trade using MIS for additional leverage (40% of NRML margin) between 9:15 AM and 3:20 PM. All open MIS positions get squared off at 3:20 PM.
    3                                                                                                                                                Please use the Bracket Order & Cover Order calculator for CO calculations
person sckott    schedule 16.02.2016