2017-09-13 5 views
0

データをスクラップしようとしましたが、タイムアウトエラーが発生しています。私のインターネットは正常に動作しています。最新バージョンのRにもアップデートしました。現時点でどのようにこれに対処するのかが分かりません。私が試したどんなURLでも起き続ける。エラー:ポート443のタイムアウト - データのスクラビング

library(RCurl) 
library(XML) 

url = "https://inciweb.nwcg.gov/" 
content <- getURLContent(url) 
    Error in function (type, msg, asError = TRUE) : 
     Failed to connect to inciweb.nwcg.gov port 443: Timed out 

答えて

1

あなたは、低速接続で明示的なタイムアウトを設定する必要があります。

library(httr) 
library(rvest) 

pg <- GET("https://inciweb.nwcg.gov/", timeout(60)) 

incidents <- html_table(content(pg))[[1]] 

str(incidents) 
## 'data.frame': 10 obs. of 7 variables: 
## $ Incident: chr "Highline Fire" "Cottonwood Fire" "Rattlesnake Point Fire" "Coolwater Complex" ... 
## $ Type : chr "Wildfire" "Wildfire" "Wildfire" "Wildfire" ... 
## $ Unit : chr "Payette National Forest" "Elko District Office" "Nez Perce - Clearwater National Forests" "Nez Perce - Clearwater National Forests" ... 
## $ State : chr "Idaho, USA" "Nevada, USA" "Idaho, USA" "Idaho, USA" ... 
## $ Status : chr "Active" "Active" "Active" "Active" ... 
## $ Acres : chr "83,630" "1,500" "4,843" "2,969" ... 
## $ Updated : chr "1 min. ago" "1 min. ago" "3 min. ago" "5 min. ago" ... 

一時的な回避策

l <- charToRaw(paste0(readLines("https://inciweb.nwcg.gov/"), collapse="\n")) 

pg <- read_html(l) 

html_table(pg)[[1]] 
+0

フム、別のタイムアウト(#)とこれを取得しておくことを試してみました: 'pg < - GET(" https://inciweb.nwcg.gov/ "、タイムアウト(60)) curl :: curl_fetch_memory(url、handle = handle)のエラー: タイムアウトに達しました:10000ミリ秒後に接続がタイムアウトしました。 ' – S31

+0

私はRで他のウェブサイトも試しましたが、同じ問題がありました。ブラウザでこれらのサイトにアクセスすると、通常 – S31

+0

のように動作します。 Windows 7を使用する – S31

関連する問題