Navigate to new URL in existing IE

amo

Board Regular
Joined
Apr 14, 2020
Messages
141
Office Version
  1. 2010
Platform
  1. Windows
How do new urls run on the internet explorer that is already open ?

Thank you for your help

VBA Code:
Sub getdata()
   
    On Error Resume Next
    
    Dim HTMLDoc As New HTMLDocument
    Dim ieBrowser As New InternetExplorer
    
    'variable to specify the row number in excel
    Dim lastRow As Integer, rowno As Integer
    Dim tag As Object
    
    lastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, "A").End(xlUp).Row
    
    
    For i = 3 To lastRow
        URLNAME = Cells(i, 1).Value
        
        ieBrowser.Visible = True
        ieBrowser.navigate URLNAME
        
        Do
       
        Loop Until ieBrowser.readyState = READYSTATE_COMPLETE
        
        Set HTMLDoc = ieBrowser.document
        
        Application.Wait (Now + TimeValue("0:00:05"))
        
        'Price
        ActiveSheet.Cells(rowno, 4) = HTMLDoc.getElementsByClassName("AJyN7v")(0).innerText
        'Stock
        ActiveSheet.Cells(rowno, 5) = HTMLDoc.getElementsByClassName("_2ZcUKh")(0).innerText
        
    Next
    Set ieBrowser = Nothing
    Set HTMLDoc = Nothing
End Sub
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi Amo,

Is there any specific reason to open site in the same browser?

As the code suggest you are scraping values from site. The code will open 3 IE windows. You can make below change if you don't need IE to open.

VBA Code:
ieBrowser.Visible = False
 
Upvote 0
Hi Amo,

Is there any specific reason to open site in the same browser?

As the code suggest you are scraping values from site. The code will open 3 IE windows. You can make below change if you don't need IE to open.

VBA Code:
ieBrowser.Visible = False
Hi @Saurabhj

because there are so many urls on the list

so far that has been running, every time finishes running a single url line ...
close the browser, and open the browser again

and it is very long and less effective
 
Upvote 0
Hi @Saurabhj

because there are so many urls on the list

so far that has been running, every time finishes running a single url line ...
close the browser, and open the browser again

and it is very long and less effective
@Saurabhj
Sorry , My code turned out to be what I expected ?‍♂️

thank you for the response ?
 
Upvote 0
@Saurabhj

hello sir

I want to ask
if the retrieved data is empty

then fill in the previous data

is there a solution?
 
Upvote 0
Yes we can. Do you have any example to check.
 
Upvote 0

Forum statistics

Threads
1,213,517
Messages
6,114,085
Members
448,548
Latest member
harryls

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top