• 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

Social websites extraction|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Social websites extraction|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 & MacrosSocial websites extraction
sp_PrintTopic sp_TopicIcon
Social websites extraction
Avatar
Ehab Ali
Member
Members
Level 0
Forum Posts: 32
Member Since:
September 26, 2018
sp_UserOfflineSmall Offline
1
September 26, 2018 - 8:37 pm
sp_Permalink sp_Print sp_EditHistory

Please i need to extract all Social websites from companies websites

Here all details:
I have a lot of companies websites and I want to collect their official Social websites by checking company website then get the Social websites.
I expect the macro will do below steps.
1- Open Company website.
2- Check all hyperlinks founded in website "home page", I mean no need to check all websites pages it is just main page like.
3- If the hyperlink contain Linkedin, macro get this link
5- If the hyperlink contain Facebook, macro get this link
6- If the hyperlink contain Twitter, macro get this link
7-If the hyperlink contain Youtube, macro get this link

I hope this applicable as I I really need it.

Many thanks for help me.

sp_AnswersTopicSeeAnswer See Answer
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
September 27, 2018 - 3:54 pm
sp_Permalink sp_Print sp_EditHistory

Hi,

See attached workbook for a good start on this.  The code in the workbook will load a page and then parse the HTML for any links. 

It will print to the ActiveSheet links for Twitter, YouTube, LinkedIn, Facebook and Google+.  You can add more social networks in the code very easily.

If you load https://www.myonlinetraininghub.com the output you get is

https://www.youtube.com/user/M.....rainingHub

https://www.facebook.com/plugi.....4919174389

https://plus.google.com/+Myonl.....ininghubA1

 

This is not foolproof as the VBA is merely looking for the occurrence of strings like 'YouTube', 'Facebook' etc within a link so any link to these sites will be listed in the ActiveSheet.

For this to work you will need to set a reference in your VBA editor : Tools > References > Microsoft HTML Object Library

Cheers

Phil

Avatar
Ehab Ali
Member
Members
Level 0
Forum Posts: 32
Member Since:
September 26, 2018
sp_UserOfflineSmall Offline
3
September 27, 2018 - 7:39 pm
sp_Permalink sp_Print sp_EditHistory

Many Thanks for help me.

Please still I need your help as I am a beginner in VBA & MACROS.

I have a lot of companies websites and I expect the Input and Output for Macro as below.

Input: Company website in column A
Output: Linkedin URL column B, Facebook URL Column C, Twitter URL Column D, Youtube URL Column E.

Please check attached file.

I'm sure you are busy, when you have a chance please reply to my request as I really need it.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
October 17, 2018 - 4:29 pm
sp_Permalink sp_Print

Hi,

Please check this post

https://www.myonlinetraininghu.....g-with-vba

Regards

Phil

sp_AnswersTopicAnswer
Answers Post
Avatar
Ehab Ali
Member
Members
Level 0
Forum Posts: 32
Member Since:
September 26, 2018
sp_UserOfflineSmall Offline
5
October 19, 2018 - 3:56 am
sp_Permalink sp_Print sp_EditHistory

Hi Philip,

I want to thank you for the great efforts.

Yes it is ok, and I will use it to collect all social websites for Companies.

I just have some questions, please can help me.

1- Suppose If the website contain two Facebook or twitter or.... , I think the macro will get one only . I'm correct?

2- I have to collect the accounts email like sales@company.co.uk from http ://www.company.co.uk/ , can you update the macro by two columns as below.

First column: Account.  Please check F column as added example.  " As sometimes the companies put their email in home page"

Second Column: Contact Page URL.  Please check F column as I added example. "As I will use contact URL to extract the emails by Running the macro again in contact URL not website home page."

Thanks;

Ehab Ali

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
October 19, 2018 - 11:42 am
sp_Permalink sp_Print

Hi Ehab,

This is where it gets difficult. To answer your first qs, as the macro is only looking for the string "facebook" in links, it will find any mention of "facebook" and as the code is written will only list one on the worksheet.

You really need to know exactly where the link is on the web page and what form it takes.  The link could be in the main body of the page, a sidebar, or in the footer.  If you know this by examining the page in the Inspector you could write code to extract it. But given that you've gone to that trouble, you may as well just copy and paste it into Excel.

So writing a generic macro to work for all sites just isn't possible because sites will be structured differently.

As for the 2nd qs, in order to find a specific email address I need to know that specific email address, and where to look for it.

The simplest way to look for an email address is to search for an @ but beyond that how do I know that the @ I have found is part of an email address and not part of something else?

Even if I wrote code to try to do further checks like make sure that after the @ there are some characters then a dot then possibly another dot and some characters I still don't know if the email address I've found is the one I want.  And bear in mind that not all email address/domains follow the structure 'something.xx.xx'

And if I find more than one @ on the page, how do I know which one is the email address I want?

Likewise for the contact page URL.  In your example workbook the 2 you have listed don't have any similarity in their structure.  One links to a page called IXYSDivisions.aspx, the other links to contact-us.  There's no way to know both of these are contact pages without actually looking at them and if you have to do that then you are back to copying/pasting the URL as being your best solution.

Sorry, you can't write code that will do what you want.

Regards

Phil

Avatar
Ehab Ali
Member
Members
Level 0
Forum Posts: 32
Member Since:
September 26, 2018
sp_UserOfflineSmall Offline
7
October 20, 2018 - 8:38 am
sp_Permalink sp_Print sp_EditHistory

Hi Philip,

Really,  I want to thank you very much for help. I appreciate your support.

I agree with you completely about all you said.

Yes all sites have different structure but I have 2 million of companies and I have to get their data like social websites, emails, contact URL,.... etc.

And I'm sure I can't do this Manually as it takes long time. may years Confused.

So I have to find any way to help me to get data for these companies as I can.

I'm in Beginner macros but I have to find solution to help me on this.

I updated the code which you wrote it and I got some data but not Quality 100%, so I will check the result and apply some checks.

Attached file is updated macro, please check.

For emails, Marco will search about  "MAILTO:" and result of macro like this " mailto:press.relations@broadcom.com "

I need your help to write two sentences in code to do below actions.

1- Remove "mailto:" from macro output to be "press.relations@broadcom.com".  I mean replace "mailto:" by no thing " ".

2- I need to collect all emails in page, so do have any way to make the macro result like press.relations@broadcom.com | karen.li@avagotech.com | sanjeet.roy@avagotech.com.   I mean collect all emails in one cell by this separator |

 

For URLs, the macro result as "about:en/contact.html" so I need your help to write one sentence to replace "about:" by the website.

Ex: website: http://www.a-bright.com.tw/  macro result: "about:en/contact.html"   so I want to be  http://www.a-bright.com.tw/en/.....ntact.html

Again, Many thanks for your efforts.

Thanks ;

Ehab Ali

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1518
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
8
October 25, 2018 - 10:04 pm
sp_Permalink sp_Print

You're still going to have to go through the results by hand to make sure they are correct.

Try this attachment.

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Brian Pham, Riny van Eekelen
Guest(s) 9
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
Jessica Stewart: 205
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
stuart burge
Bruce Tang Nian
Scot C
Othman AL MUTAIRI
Misael Gutierrez Sr.
Attif Ihsan
Kieran Fee
Murat Hasanoglu
Brett Dryland
Saeed Aldousari
Forum Stats:
Groups: 3
Forums: 24
Topics: 6223
Posts: 27295

 

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