• 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
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Scrape Address from Web Page|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Scrape Address from Web Page|VBA & Macros|Excel Forum|My Online Training Hub
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 & MacrosScrape Address from Web Page
sp_PrintTopic sp_TopicIcon
Scrape Address from Web Page
Avatar
Reshera Reshera

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
March 18, 2020
sp_UserOfflineSmall Offline
1
March 18, 2020 - 3:25 am
sp_Permalink sp_Print sp_EditHistory

Hi Phil,

 

Im an absolut beginner (so far just a bit of vba) and are currently just trying to get a grip on your code. Thanks for that!

Your Code:

                    HTML.body.innerHTML = http.responseText
                           
                    Set links = HTML.getElementsByTagName("a")
                    For Each link In links
                    Cells(Cells(Rows.Count, "F").End(xlUp).row + 1, "F").Value = link.href
                    Next

Im wondering, you are looking for "<a" and you are extracting everything in between. I see how that works. In my case, I would like to extract the address, but I can’t detect what to search for in this case. Because the <address> sits between two closed brakets...

The code I get from the website:

    

<address>

           <b><a class="details-link" href="/0ewtewgs1"> Name of company</a></b><br>

           Main Street<br>

           80809 München<br>

               Fon: 3434325325235<br>

           <a href="mailto:info@gmail.de">info@gmail.de</a><br>

       </address>

 

What do I have to code to get:

 

Name of company

Main Street

80809 München

Fon: 3434325325235

info@gmail.de

 

Thanks a lot for your help and greetings from Germany!

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
March 18, 2020 - 8:46 am
sp_Permalink sp_Print

Hi Reshera,

What website are you trying to get this from?

Phil

Avatar
Reshera Reshera

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
March 18, 2020
sp_UserOfflineSmall Offline
3
March 18, 2020 - 4:55 pm
sp_Permalink sp_Print

Hi Phil,

 

thanks for your promt reply. Unfortunately I cant name the Website here. It shows the addresses where to find their stores. Can You help me nevertheless?

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
March 19, 2020 - 2:43 pm
sp_Permalink sp_Print sp_EditHistory

Hi Reshera,

I can only give you generic code without seeing the actual site.  This worked with a dummy HTML file I created.

Option Explicit

' Written by Philip Treacy
' https://www.myonlinetraininghub.com/web-scraping-filling-forms

Sub Scrape()

    Dim Driver As New Selenium.ChromeDriver
    Dim URL As String
    Dim addresses As Object
    Dim address As Variant
    
   URL = "website-address"
   
    
    Set Driver = CreateObject("Selenium.ChromeDriver")
    
    Driver.Get URL
    
    Set addresses = Driver.FindElementsByTag("address").Text
        
        
    For Each address In addresses
        
        Debug.Print address
            
    Next
            
    Driver.Quit
        
End Sub

 

You'll need to use the SeleniumBasic driver to get this to work, I couldn't get native VBA to work.  Not sure it understood the <address>tags.

The attached workbook is adapted from this post

https://www.myonlinetraininghu.....ling-forms

Cheers

Phil

Avatar
Reshera Reshera

Active Member
Members
Level 0
Forum Posts: 3
Member Since:
March 18, 2020
sp_UserOfflineSmall Offline
5
March 23, 2020 - 1:07 am
sp_Permalink sp_Print

Hi Phil,

 

thank You very much. Ill try if I can figure that out.

 

Meanwhile, I just used another tag "div", which extracted a huge sequence of text which I have to seperate into the sections im looking for later on. Pretty sure, ist not a nice way to do it cause it creates an insane amount of data, but at least i can get what im lookin for.

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Denise Lloyd
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Raj Mattoo
Mark Luke
terimeri dooriyan
Jack Aston
AndyC
Denise Lloyd
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Forum Stats:
Groups: 3
Forums: 24
Topics: 6219
Posts: 27276

 

Member Stats:
Guest Posters: 49
Members: 31903
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.