I trying to get data from table. I'm using Selenium.ChromeDriver. XPath print it out like this //*[@id="foundCompanies"]/tbody/tr/td[2]. I try to follow this tutorial
Web Scraping – Filling in Forms
,for my own purpose.
Also I need timer to send request 10 second interval.
Thank You.
Hi Hannu,
You'll have to be more specific as I don't understand enough about the problem.
Please include a link to the site you are trying to access and attach the workbook with the code you are using.
Regards
Phil
There were also 2 attachments in that post, but they seem to be missing / deleted. The problem is when I try to run that vba file, the Chrome window just flashes and it doesn't get data out of the table.
From the first page (table), it should click on the Business ID. Then a new page(table) opens and i want data from that table to columns B,C,D etc. I hope those attachments clarify the situation.
Okay. I got it yesterday to act like a blog text. The only pity I have anymore is how do I make it work so that if the information in column A is not
found on the search site, it would start over.
There are now many points where it can find the error, but I would like that when it notices the error write what it already found, otherwise print null.
I would be grateful if someone could help.
Maybe this is the wrong forum to askhelp, but when the original code was found here I thought I would ask for help here.
This is a school project for which I need that data. All the data I tried to request (csv or excel) is chargeable, hence this webscraping.
There are over 35,000 rows that should run through this. LoL.
Hi Hannu,
Please post your most up to date code, so I can see where you are up to.
regards
Phil
Hi Philip,
My latest version of that code. There's not much new.
regards
Hannu
Hi Hannu,
When the search returned nothing, a pop-up was created in the Chrome browser - didn't you see this?
Because your code was looking for elements on the main page/window rather than dealing with the pop-up, this was causing the error.
I've added a section that checks for the error generated by trying to click an element when the pop-up is visible.
On Error Resume Next
Driver.Wait 2000
Driver.FindElementById("_ctl0_cphSisalto_rptHakuTulos__ctl1_HyperLink1").Click
If Err.Number > 0 Then
Driver.SwitchToAlert.Accept
Else
Driver.Wait 1000
Range("B" & count) = Driver.FindElementById("_ctl0_cphSisalto_lblytunnus").Text
Range("C" & count) = Driver.FindElementById("_ctl0_cphSisalto_lblYrityksenKotipaikka").Text
Range("D" & count) = Driver.FindElementById("_ctl0_cphSisalto_lblToiminimi").Text
Range("E" & count) = Driver.FindElementById("_ctl0_cphSisalto_lblYrityksenToimiala").Text
End If
On Error GoTo 0
So if this pop-up is there, the code will now dismiss it and then move on to the next search. See attached file.
Regards
Phil
Yes, I noticed that pop-up on chrome browser. I tried some error handler for those errors, but I couldn't make it work.
Now it's working as it should.
Thank you so much for your efforts.
Regards
Hannu
I just can't thank you enough.
no worries.