I'm trying to verify the links I scraped were saved in the Wayback Machine. There are two possible outcomes: 1) The link has been saved in the archive and 2) it has not been saved in the archive.
If the link has not been saved in the archive, I would like the driver to save the link, sleep for 30s, and then navigate back to the main page.
If the link has been saved to the page, I want the driver to go back to the main page and start the process again.
I'm not sure how to tell the driver to recognize these two scenarios. Any advice?
library(RSelenium); library(netstat)
# start server
remote_driver = rsDriver(browser = 'firefox',
verbose = F,
port = free_port())
rd = remote_driver$client
rd$open()
rd$navigate('https://web.archive.org/web/')
rd$maxWindowSize()
links = c('https://www.bjjcompsystem.com/tournaments/1869/categories?gender_id=2','https://www.bjjcompsystem.com/tournaments/1869/categories/2053485','https://www.bjjcompsystem.com/tournaments/1869/categories/2053677')
for (i in 1:3){
rd$navigate('https://web.archive.org/web/')
Check_archive = rd$findElement(using = 'xpath', '//*[contains(concat( " ", @class, " " ), concat( " ", "focus", " " ))]')
Check_archive$clickElement()
Check_archive$sendKeysToElement(list(links[i], key='enter'))
Sys.sleep(5)
# INSERT IF STATMENT HERE
save = rd$findElement(using = 'link text', 'Save this URL in the Wayback Machine')
save$clickElement()
Sys.sleep(30)
}