@@ -53,11 +53,17 @@ random_page <- function(language = NULL, project = NULL, domain = NULL,
5353 clean_response = FALSE , ... ){
5454
5555
56- url <- url_gen(language , project , domain , " &action=query&list=random&rnlimit=" , limit )
56+ url <- url_gen(language , project , domain )
57+ query_param <- list (
58+ action = " query" ,
59+ list = " random" ,
60+ rnlimit = limit
61+ )
62+
5763 if (! is.null(namespaces )){
58- url <- paste0( url , " &rnnamespace= " , paste(namespaces , collapse = " |" ) )
64+ query_param $ rnnamespace <- paste(namespaces , collapse = " |" )
5965 }
60- pages <- query(url , NULL , FALSE )$ query $ random
66+ pages <- query(url , NULL , FALSE , query_param = query_param )$ query $ random
6167
6268 return (lapply(pages , function (page , language , project , domain , page_name , as_wikitext ,
6369 clean_response , ... ){
@@ -122,17 +128,19 @@ page_content <- function(language = NULL, project = NULL, domain = NULL,
122128 properties <- " text|revid"
123129 }
124130 properties <- paste(properties , collapse = " |" )
125- url <- url_gen(language , project , domain , " &action=parse&prop=" , properties )
131+ url <- url_gen(language , project , domain )
132+ query_param <- list (
133+ action = " parse" ,
134+ prop = properties
135+ )
126136 if (! is.null(page_id )){
127- page_id <- handle_limits(page_id , 1 )
128- url <- paste0(url , " &pageid=" , page_id )
137+ query_param $ page_id <- handle_limits(page_id , 1 )
129138 } else {
130- page_name <- handle_limits(page_name , 1 )
131- url <- paste0(url , " &page=" , page_name )
139+ query_param $ page <- handle_limits(page_name , 1 )
132140 }
133141
134142 # Run
135- content <- query(url , " pcontent" , clean_response , ... )
143+ content <- query(url , " pcontent" , clean_response , query_param = query_param , ... )
136144
137145 # Return
138146 return (content )
@@ -194,12 +202,17 @@ revision_content <- function(language = NULL, project = NULL, domain = NULL,
194202 properties <- match.arg(arg = properties , several.ok = TRUE )
195203 properties <- paste(properties , collapse = " |" )
196204 revisions <- handle_limits(revisions , 50 )
197- url <- url_gen(language , project , domain ,
198- " &rvcontentformat=text/x-wiki&action=query&prop=revisions&rvprop=" ,
199- properties , " &revids=" ,revisions )
205+ url <- url_gen(language , project , domain )
206+ query_param <- list (
207+ rvcontentformat = " text/x-wiki" ,
208+ action = " query" ,
209+ prop = " revisions" ,
210+ rvprop = properties ,
211+ revids = revisions
212+ )
200213
201214 # Run
202- content <- query(url , " rcontent" , clean_response , ... )
215+ content <- query(url , " rcontent" , clean_response , query_param = query_param , ... )
203216
204217 # Check for invalid RevIDs
205218 invalid_revs(content )
@@ -277,13 +290,19 @@ revision_diff <- function(language = NULL, project = NULL, domain = NULL,
277290 properties <- match.arg(properties , several.ok = TRUE )
278291 properties <- paste(properties , collapse = " |" )
279292 revisions <- handle_limits(revisions , 50 )
280- url <- url_gen(language , project , domain , " &action=query&prop=revisions&rvprop=" ,
281- properties , " &rvdiffto=" , direction , " &rvcontentformat=text/css&revids=" ,
282- revisions )
293+ url <- url_gen(language , project , domain )
294+ query_param <- list (
295+ action = " query" ,
296+ prop = " revisions" ,
297+ rvprop = properties ,
298+ rvdiffto = direction ,
299+ rvcontentformat = " text/css" ,
300+ revids = revisions
301+ )
283302
284303 # Retrieve the content, check for invalid RevIDs and uncached diffs,
285304 # return.
286- content <- query(url , " rdiff" , clean_response , ... )
305+ content <- query(url , " rdiff" , clean_response , query_param = query_param , ... )
287306 invalid_revs(content )
288307 if (sum(grepl(x = names(unlist(content )), pattern = " diff.notcached" ))){
289308 warning(" This request contained uncached diffs; these will not be returned" , call. = FALSE )
0 commit comments