Forum

Need help to get da...
 
Notifications
Clear all

Need help to get data from table

10 Posts
2 Users
0 Reactions
114 Views
(@remuli)
Posts: 6
Active Member
Topic starter
 

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. 

 
Posted : 18/11/2020 11:21 am
Philip Treacy
(@philipt)
Posts: 1632
Member Admin
 

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

 
Posted : 18/11/2020 8:54 pm
(@remuli)
Posts: 6
Active Member
Topic starter
 
first_table.PNGsecond_table.PNGThere 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.
 
Posted : 19/11/2020 12:43 am
(@remuli)
Posts: 6
Active Member
Topic starter
 
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.
 
 
Posted : 21/11/2020 3:21 pm
Philip Treacy
(@philipt)
Posts: 1632
Member Admin
 

Hi Hannu,

Please post your most up to date code, so I can see where you are up to.

regards

Phil

 
Posted : 22/11/2020 9:39 pm
(@remuli)
Posts: 6
Active Member
Topic starter
 

Hi Philip,

My latest version of that code. There's not much new.

 

regards

Hannu

 
Posted : 23/11/2020 6:16 am
Philip Treacy
(@philipt)
Posts: 1632
Member Admin
 

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

 
Posted : 25/11/2020 12:50 am
(@remuli)
Posts: 6
Active Member
Topic starter
 

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

 
Posted : 25/11/2020 7:52 am
(@remuli)
Posts: 6
Active Member
Topic starter
 

I just can't thank you enough.

 
Posted : 25/11/2020 7:27 pm
Philip Treacy
(@philipt)
Posts: 1632
Member Admin
 

no worries.

 
Posted : 25/11/2020 8:25 pm
Share: