不知道這是你想要的,因爲我找不到aprox列表。 50-100只股票。
但爲了什麼值得使用SelectorGadget我想出了這個節點.table-dark-row:nth-child(2).snapshot-td2:nth-child(2),選擇Market Cap(first在本頁第二行http://www.finviz.com/quote.ashx?t=AA&ty=c&p=d&b=1)。
> library(rvest)
>
> html = read_html("http://www.finviz.com/quote.ashx?t=AA&ty=c&p=d&b=1")
>
> cast = html_nodes(html, ".table-dark-row:nth-child(2) .snapshot-td2:nth-child(2)")
> cast
{xml_nodeset (1)}
[1] <td width="8%" class="snapshot-td2" align="left">\n <b>11.58B</b>\n</td>
>
如果這不正是你想要的,只需使用SelectorGadget來找到你想要的。
希望這會有所幫助。
編輯:
這裏完整的解決方案:
library(rvest)
html = read_html("http://www.finviz.com/quote.ashx?t=AA&ty=c&p=d&b=1")
cast = html_nodes(html, ".table-dark-row:nth-child(2) .snapshot-td2:nth-child(2)")
html_text(cast) %>%
gsub(pattern = "B", replacement = "") %>%
as.numeric()
這一個似乎很合法的。我需要弄清楚如何從字符串中提取數字。 –
在同一個'rvest'包中使用函數'html_text()'。 'html_text(cast)'給你「12.76B」,然後,將它轉換爲數字,你需要擺脫B(我不知道它是什麼意思)。我編輯回答。檢查那裏的完整解決方案。 – elikesprogramming