• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Need help to get data from table|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Need help to get data from table|VBA & Macros|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosNeed help to get data from table
sp_PrintTopic sp_TopicIcon
Need help to get data from table
Avatar
Hannu Illikainen
Member
Members
Level 0
Forum Posts: 6
Member Since:
November 18, 2020
sp_UserOfflineSmall Offline
1
November 18, 2020 - 1:21 am
sp_Permalink sp_Print

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. 

sp_AnswersTopicSeeAnswer See Answer
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
November 18, 2020 - 10:54 am
sp_Permalink sp_Print

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

Avatar
Hannu Illikainen
Member
Members
Level 0
Forum Posts: 6
Member Since:
November 18, 2020
sp_UserOfflineSmall Offline
3
November 18, 2020 - 2:43 pm
sp_Permalink sp_Print sp_EditHistory
first_table.PNGImage Enlarger
second_table.PNGImage Enlarger
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.
sp_PlupAttachments Attachments
  • sp_PlupImage first_table.PNG (86 KB)
  • sp_PlupImage second_table.PNG (180 KB)
Avatar
Hannu Illikainen
Member
Members
Level 0
Forum Posts: 6
Member Since:
November 18, 2020
sp_UserOfflineSmall Offline
4
November 21, 2020 - 5:21 am
sp_Permalink sp_Print sp_EditHistory
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.
 
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
5
November 22, 2020 - 11:39 am
sp_Permalink sp_Print

Hi Hannu,

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

regards

Phil

Avatar
Hannu Illikainen
Member
Members
Level 0
Forum Posts: 6
Member Since:
November 18, 2020
sp_UserOfflineSmall Offline
6
November 22, 2020 - 8:16 pm
sp_Permalink sp_Print sp_EditHistory

Hi Philip,

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

 

regards

Hannu

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
7
November 24, 2020 - 2:50 pm
sp_Permalink sp_Print

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

Avatar
Hannu Illikainen
Member
Members
Level 0
Forum Posts: 6
Member Since:
November 18, 2020
sp_UserOfflineSmall Offline
8
November 24, 2020 - 9:52 pm
sp_Permalink sp_Print

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

sp_AnswersTopicAnswer
Answers Post
Avatar
Hannu Illikainen
Member
Members
Level 0
Forum Posts: 6
Member Since:
November 18, 2020
sp_UserOfflineSmall Offline
9
November 25, 2020 - 9:27 am
sp_Permalink sp_Print

I just can't thank you enough.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1529
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
10
November 25, 2020 - 10:25 am
sp_Permalink sp_Print

no worries.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Bright Asamoah
Guest(s) 12
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 218
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Gilbert Lemek
Ashleigh Farquharson
Jayz Luu
Fred Smith
Charles DeGraffenreaid
Cathi Giard
Sarah Young
Henry Delgado
Alita Nieuwoudt
KL KOH
Forum Stats:
Groups: 3
Forums: 24
Topics: 6360
Posts: 27812

 

Member Stats:
Guest Posters: 49
Members: 32340
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.