此屏幕截图中是否有CSS选择器?

时间:2018-09-22 04:44:37

标签: css r

enter image description here

我尝试使用[href * =“ genome”]和[title〜= Eukaryota],但是Rstudio给我一个错误消息,指出Argument是无效的选择器(例如XPath / CSS)。

有关更多信息,

remDr <- RSelenium::remoteDriver(remoteServerAddr = "127.0.0.1",
                             port = 4445L,
                             browserName = "chrome")
element <- remDr$findElement(using = 'css selector', "selector")

1 个答案:

答案 0 :(得分:1)

使用此测试HTML文件:

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.android.support:design:28.0.0-rc01.

并使用<html> <head> <title>hello</title> </head> <body> <a href="./gen_list.cgi?genome=hs" title="Euk; Opi; Meta">Foo</a> <a href="./home" title="Home">Home</a> </body> </html> 包,我可以使用rvesta的匹配项来选择href标签:

title

所以我认为“对我有用”在这里适用-也许RSelenium的实现不如> html = read_html("sample.html") > html_nodes(html,'a[title~="Euk;"]') {xml_nodeset (1)} [1] <a href="./gen_list.cgi?genome=hs" title="Euk; Opi; Meta">Foo</a> > html_nodes(html,'a[href*="genome"]') {xml_nodeset (1)} [1] <a href="./gen_list.cgi?genome=hs" title="Euk; Opi; Meta">Foo</a> 完整?微小的示例通常值得测试,因此请使用我的示例。不是特别rvest选择器匹配标题中用空格分隔的单词,因此您需要在~=末尾使用分号-您的标题字符串似乎是用空格分隔的,这样才可以使用。