googlesearchconsoleR中的Google Search Console API正则表达式

时间:2018-06-21 10:56:34

标签: r google-api google-search-console

是否可以在searchconsoleR库中使用正则表达式?

在R中,我尝试过滤所有包含“ listing /”的URL(代码波纹管),但是r返回“ as.character(x)中的错误:无法将类型“ closure”强制转换为类型“ character”的向量” >

我的代码:

dane3 <- search_analytics(siteURL = "https://www.***.**" , 
startDate = "2018-06-01", 
endDate = "2018-06-01", 
dimensions = c("date" , "query" , "page") ,
dimensionFilterExp = grep(".*listing\/.*", page, ignore.case = FALSE, perl = FALSE, value = FALSE,
      fixed = FALSE, useBytes = FALSE, invert = FALSE)

2 个答案:

答案 0 :(得分:0)

我无法用grep()部分复制相同的错误。我的错误是Error: '\/' is an unrecognized escape in character string starting "".*listing\/",这意味着/不是应该转义的字符。选中this doc。因此,您的代码应如下所示:

grep(".*listing/.*", data2$names, ignore.case = FALSE, perl = FALSE, value = FALSE,
    fixed = FALSE, useBytes = FALSE, invert = FALSE)

答案 1 :(得分:0)

您不能在过滤器中使用正则表达式,最接近的是对不包含使用!~,对包含使用~~

例如列出包含“等等”使用的页面

page~~blah