0
私はウェブページをページ単位でスクラップする必要があるプロジェクトに取り組んでいます。各ページに約81のリンクがあります。私はこれらのリンクをこすり、リンク内のデータを解析する必要があります。最初のページのリンクを削ってみると、リンクの完全なアドレスは表示されません。ここに私のコードは次のとおりです。フルリンクURLがウェブスクレイピングで表示されないR
library(rvest)
main.page <- read_html(x="https://www.sec.gov/cgi-bin/srch-edgar. text=abs-ee&start=1&count=80&first=2016&last=2017")
urls <- main.page %>%
html_nodes("div td:nth-child(2) a")%>%
html_attr("href")
links <- main.page %>%
html_nodes ("div td:nth-child(2) a") %>%
html_text()
sotu <- data.frame(urls=urls,links=links, stringsAsFactors = FALSE)
for (in in nrow(sotu)) {
second.page<- read_html(sotu$urls[i])
html_nodes<- (".blueRow:nth-child(3) a") %>%
html_text()
}
私はリンクが存在しないというエラーを取得しておきます。これは、Rでのリンクの表示方法です。
/Archives/edgar/data/1347185/000134718517000016/0001347185-17-000016-index.htm
2 /Archives/edgar/data/1347185/000134718517000010/0001347185-17-000010-index.htm
3 /Archives/edgar/data/1477336/000167973117000023/0001679731-17-000023-index.htm
4 /Archives/edgar/data/1477336/000170066717000013/0001700667-17-000013-index.htm
5 /Archives/edgar/data/1477336/000170500217000002/0001705002-17-000002-index.htm
6 /Archives/edgar/data/1477336/000167973117000017/0001679731-17-000017-index.htm
7 /Archives/edgar/data/1477336/000170066717000009/0001700667-17-000009-index.htm
8 /Archives/edgar/data/1477336/000167973117000012/0001679731-17-000012-index.htm
9 /Archives/edgar/data/1477336/000170066717000003/0001700667-17-000003-index.htm
10 /Archives/edgar/data/1477336/000167973117000006/0001679731-17-000006-index.htm
11 /Archives/edgar/data/1477336/000147733617000006/0001477336-17-000006-index.htm
12 /Archives/edgar/data/1679731/000167973117000023/0001679731-17-000023-index.htm
リンクが相対的であるようです。削られているページをURLの先頭に追加するだけです。 –
as: 'https:// www.sec.gov/Archives/edgar/data/1347185/000134718517000016/0001347185-17-000016-index.htm' –
すべてのURLにメインページを自動的に追加するにはどうすればよいですか? – aa710