ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Import images from a website (https://www.excelbanter.com/excel-programming/419337-import-images-website.html)

Thyag

Import images from a website
 
Hi

I have a web page with many ( more than 250 ) hyperlinks.When we click
on any hyperlink a new web page with some images open.

I need to import all the images to excel.
Can some body say what is the ideal way of doing this.

For any additional details/clarification please post back.


Thanks
Thyag




joel

Import images from a website
 
This code it will give you an idea of what can be done. It wil automaically
create a worksheet Chemicals and then get over 5000 chekicals with the
webpages they are located. The hyperlink address on these webpages are not
visibble but can be returned as you will see with this code.

Sub Getchemicals2()

Found = False
For Each sht In Sheets
If sht.Name = "Chemicals" Then
Found = True
Exit For
End If
Next sht
If Found = False Then
Set ChemicalSht = Sheets.Add(after:=Sheets(Sheets.Count))
ChemicalSht.Name = "Chemicals"
Else
Sheets("Chemicals").Cells.ClearContents
Set ChemicalSht = Sheets("Chemicals")
End If


Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

URLFolder = _

"http://www.ilo.org/public/english/protection/safework/cis/products/icsc/dtasht/"
ChemicalRowCount = 1
For Letters = 0 To 25
AlphaLetter = Chr(Asc("a") + Letters)

URL = URLFolder & AlphaLetter & "_index.htm"

'get web page
IE.Navigate2 URL
Do While IE.readyState < 4
DoEvents
Loop

Do While IE.busy = True
DoEvents
Loop

H2Found = False
For Each itm In IE.document.all
If H2Found = False Then
If itm.tagname = "H2" Then
H2Found = True
End If
Else

If itm.tagname = "A" Then
If itm.innertext = "" Then Exit For

'chemical name
ChemicalSht.Range("A" & ChemicalRowCount) = itm.innertext
'webpage
ChemicalSht.Range("B" & ChemicalRowCount) = itm.href

ChemicalRowCount = ChemicalRowCount + 1
End If
End If
Next itm

Next Letters


End Sub


"Thyag" wrote:

Hi

I have a web page with many ( more than 250 ) hyperlinks.When we click
on any hyperlink a new web page with some images open.

I need to import all the images to excel.
Can some body say what is the ideal way of doing this.

For any additional details/clarification please post back.


Thanks
Thyag






All times are GMT +1. The time now is 10:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com