【发布时间】:2020-04-06 06:35:21
【问题描述】:
我从网站上抓取了以下文字:
\n\tsfw=1;\n\tcaptions=[[\"2017-05\",2850],[\"2017-06\",3450],[\"2017-07\",3350],[ \"2017-08\",3650],[\"2017-09\",4250],[\"2017-10\",4600],[\"2017-11\",4750],[\" 2017-12\",5500],[\"2018-01\",7300],[\"2018-02\",7700],[\"2018-03\",11350],[\"2018- 04\",10900],[\"2018-05\",11500],[\"2018-06\",10800],[\"2018-07\",13200],[\"2018-08\ ",14200],[\"2018-09\",15900],[\"2018-10\",19700],[\"2018-11\",21800],[\"2018-12\", 18300],[\"2019-01\",18550],[\"2019-02\",18150],[\"2019-03\",18050],[\"2019-04\",18850] ,[\"2019-05\",71000],[\"2019-06\",83200],[\"2019-07\",72650],[\"2019-08\",80400],[ \"2019-09\",100600],[\"2019-10\",114000],[\"2019-11\",110250],[\"2019-12\",107100],[\" 2020-01\",116050],[\"2020-02\",117950],[\"2020-03\",145350]];\n我想提取数字“2850”、“3450”等文本。您能说明如何为此编写正则表达式吗?谢谢。
下面是爬取r中文字的代码:
webpage <- read_html("https://imgflip.com/meme/Drake-Hotline-Bling")
text <- html_nodes(webpage,xpath = '//script') %>% html_text()
text <- text[8]
【问题讨论】:
-
请将字符串添加为
dput,我们可以将其复制/粘贴到我们的 R 会话中。可能这会有所帮助stackoverflow.com/questions/14543627/…