不知道这是你想要的,因为我找不到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