Example CT posts/search code?
networks1 opened this issue · 2 comments
networks1 commented
You guys used to offer a worked example of how to run CooRNet via a CT posts/search call. The current code example assumes I'm seeding the search with links from from MediaCloud, which is not what I want to do. Is the posts/search functionality gone? If not can you please include a brief example of how to execute that?
fabiogiglietto commented
Hi Steve,
you have two options here:
- Getting a search or historical CSV from CrowdTangle web interface and doing something like this to get your urls:
library("readr")
library("CooRnet")
# setup working spaces with data and rawdata folders
dir.create("./data/")
dir.create("./rawdata/")
# set the link to CrowdTangle CSV file\
allpostsfile <- "LINK-TO-CSV"
# un-comment the following lines if you want to inspect the CSV file
# df <- read.csv(allpostsfile)
# names(df)
# head(df)
urls <- CooRnet::get_urls_from_ct_histdata(ct_histdata_csv = allpostsfile,
newformat = TRUE)
nrow(urls) # get the number of URLs
names(urls) # list the columns name
write.csv(urls, "./data/urls.csv") # save the list of URLs on disk
- As you pointed out, you can get the post to extract the links from by directly querying the posts/search endpoint of the API (this is great for automation). I don't have a code example at hand but you can start from this function to adapt the code to extract links from a set of posts retrieved via posts/search.
Hope it helps! Best, Fabio
networks1 commented
Hi Fabio. I thought at one time I could give it my api key and some keywords, and say “go”. Maybe I’m misremembering that.
Thank you for the response and the software also!
Best…
Steve
From: Fabio Giglietto ***@***.***>
Sent: Monday, February 20, 2023 12:44 AM
To: fabiogiglietto/CooRnet ***@***.***>
Cc: Steven Corman ***@***.***>; Author ***@***.***>
Subject: Re: [fabiogiglietto/CooRnet] Example CT posts/search code? (Issue #36)
Hi Steve,
you have two options here:
1. Getting a search or historical CSV from CrowdTangle web interface and doing something like this to get your urls:
library("readr")
library("CooRnet")
# setup working spaces with data and rawdata folders
dir.create("./data/")
dir.create("./rawdata/")
# set the link to CrowdTangle CSV file\
allpostsfile <- "LINK-TO-CSV"
# un-comment the following lines if you want to inspect the CSV file
# df <- read.csv(allpostsfile)
# names(df)
# head(df)
urls <- CooRnet::get_urls_from_ct_histdata(ct_histdata_csv = allpostsfile,
newformat = TRUE)
nrow(urls) # get the number of URLs
names(urls) # list the columns name
write.csv(urls, "./data/urls.csv") # save the list of URLs on disk
1. As you pointed out, you can get the post to extract the links from by directly querying the posts/search endpoint of the API (this is great for automation). I don't have a code example at hand but you can start from this function<https://urldefense.com/v3/__https:/github.com/fabiogiglietto/CooRnet/blob/master/R/query_link_endpoint.R__;!!IKRxdwAv5BmarQ!YPBiSA02pDhErdkqj9_rjGkJwY8oRS9_J5EAlwMeSE7spR5p2Bgc4aeGSAb-9ECB8_9LwTNBku510vkRyaxwn7Efzpo$> to adapt the code to extract links from a set of posts retrieved via posts/search.
Hope it helps! Best, Fabio
—
Reply to this email directly, view it on GitHub<https://urldefense.com/v3/__https:/github.com/fabiogiglietto/CooRnet/issues/36*issuecomment-1436489213__;Iw!!IKRxdwAv5BmarQ!YPBiSA02pDhErdkqj9_rjGkJwY8oRS9_J5EAlwMeSE7spR5p2Bgc4aeGSAb-9ECB8_9LwTNBku510vkRyaxwpgMF-eo$>, or unsubscribe<https://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/ACFXZ4ZAYLPVUCZGMUTCMTTWYMODHANCNFSM6AAAAAAVBB4COE__;!!IKRxdwAv5BmarQ!YPBiSA02pDhErdkqj9_rjGkJwY8oRS9_J5EAlwMeSE7spR5p2Bgc4aeGSAb-9ECB8_9LwTNBku510vkRyaxw5JXqVA8$>.
You are receiving this because you authored the thread.Message ID: ***@***.***>