This might be confusing, but I’ll try my best to explain:
I’m using Selenium with a current Chromedriver to scrape a website, through Excel VBA.
The code has worked perfectly for 2 months but today, the code doesn’t work. The output is returning empty.
When I pause the code execution in VBA and step into the VBA module and manually execute the code line by line by pressing F8, it also doesn’t work (not surprising) and all the elements return an empty value. (I’m obtaining the values for the elements by navigating to their full XPath)
However, while the VBA execution is paused, if I go to the website I’m scraping and copy the full xpath from the INSPECT module and paste it into my VBA code, the code works again and each element comes back with a value. The copied/pasted xpath is exactly the same as it is written in my code. Exactly the same.
On the next iteration, the code stops working again.
For some reason, copying and pasting from the INSPECT module on Chrome makes the code work temporarily and I can’t figure out why.
Set checkList = CL.FindElementsByClass("element")
clCount = CL.FindElementsByClass("element").Count
cardInt = 2
On Error Resume Next
For Each card In checkList
cardTitle = card.FindElementByXPath("xpath-and-variable-li-element-here").Text
cardTeam = card.FindElementByXPath("xpath-and-variable-li-element-here").Text
cardSport = card.FindElementByXPath("xpath-and-variable-li-element-here").Text
cardATT = card.FindElementByXPath("xpath-and-variable-li-element-here").Text
Cells(cardInt, 1).Select
Cells(cardInt, 2) = cardTitle
Cells(cardInt, 3) = cardTeam
Cells(cardInt, 4) = cardSport
Cells(cardInt, 5) = cardATT
Cells(cardInt, 6) = "Ungraded"
Cells(cardInt, 7) = "Near mint or better"
cardInt = cardInt + 1
If cardInt > clCount Then
GoTo formatting
End If
Next card
NV Sportscards is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.