Navigate to new URL in existing IE

amo

Board Regular
Joined
Apr 14, 2020
Messages
79
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
 

Some videos you may like

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Saurabhj

Active Member
Joined
Jun 6, 2020
Messages
413
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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
 

amo

Board Regular
Joined
Apr 14, 2020
Messages
79
Office Version
  1. 2010
Platform
  1. Windows
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
 

amo

Board Regular
Joined
Apr 14, 2020
Messages
79
Office Version
  1. 2010
Platform
  1. Windows
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 🙏
 

Saurabhj

Active Member
Joined
Jun 6, 2020
Messages
413
Office Version
  1. 365
  2. 2019
Platform
  1. Windows

ADVERTISEMENT

That's great. Thanks for feedback.
 

amo

Board Regular
Joined
Apr 14, 2020
Messages
79
Office Version
  1. 2010
Platform
  1. Windows
@Saurabhj

hello sir

I want to ask
if the retrieved data is empty

then fill in the previous data

is there a solution?
 

Saurabhj

Active Member
Joined
Jun 6, 2020
Messages
413
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Yes we can. Do you have any example to check.
 

Watch MrExcel Video

Forum statistics

Threads
1,126,929
Messages
5,621,656
Members
415,849
Latest member
PhoenixRising2015

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
Top