Browse Source

Merge branch 'useless_if' of vincent/ilfs-data into master

janwey 1 year ago
parent
commit
8ea49086f2
1 changed files with 13 additions and 12 deletions
  1. 13
    12
      collecto.R

+ 13
- 12
collecto.R View File

@@ -274,20 +274,15 @@ reto <- c()
274 274
 favs <- c()
275 275
 murl <- c()
276 276
 acct <- c()
277
+mastodon_instance <- "https://mastodon.social"
278
+mastodon_hashtag <- "ilovefs"
279
+mastodon_url <- paste0(mastodon_instance,
280
+                       "/api/v1/timelines/tag/",
281
+                       mastodon_hashtag,
282
+                       "?limit=40")
277 283
 for(i in 1:999){
278
-  if(i == 1){
279
-    mastodon_instance <- "https://mastodon.social"
280
-    mastodon_hashtag <- "ilovefs"
281
-    mastodon_url <- paste0(mastodon_instance,
282
-			      "/api/v1/timelines/tag/",
283
-			      mastodon_hashtag,
284
-			      "?limit=40")
285
-  } else {
286
-  mastodon_lheader <- parse_headers(mastodon_reqres$headers)[11]
287
-  mastodon_next <- sub(x = mastodon_lheader, pattern = ".*link:\ <", replace = "")
288
-  mastodon_url <- sub(x = mastodon_next, pattern = ">;\ rel=\"next\".*", replace = "")
289
-  }
290 284
   mastodon_reqres <- curl_fetch_memory(mastodon_url)
285
+
291 286
   mastodon_rawjson <- rawToChar(mastodon_reqres$content)
292 287
   toots <- fromJSON(mastodon_rawjson)
293 288
 
@@ -305,6 +300,12 @@ for(i in 1:999){
305 300
   } else {
306 301
     break
307 302
   }
303
+
304
+  # Update the URL for the next iteration of the for loop so we can download
305
+  # the next toots.
306
+  mastodon_lheader <- parse_headers(mastodon_reqres$headers)[11]
307
+  mastodon_next <- sub(x = mastodon_lheader, pattern = ".*link:\ <", replace = "")
308
+  mastodon_url <- sub(x = mastodon_next, pattern = ">;\ rel=\"next\".*", replace = "")
308 309
 }
309 310
 
310 311
 ### Time of post

Loading…
Cancel
Save