Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    May 2003
    Posts
    29
    Thanks
    3
    Thanked 1 Time in 1 Post

    Page Cannot be displayed when automated IE

    Although the page will load fine if checking it manually in chrome, when running through IE I get a page cannot be displayed error - this is possibly IE related rather than VBA, but as I'd need code to fix it (as I cannot rely on the users) I thought I'd post here - any help much appreciated. My macro (which works on other sites - because I haven't got it to run I'm not certain I'm pulling the right data if anyone wonders) is

    Private Sub PL_Scraper()
    'comes up with page cannot be displayed in IE
    Dim dd As String
    Dim prodID As String


    Dim IE As Object
    Dim looper As Long
    Dim retry As Long
    Dim SideLooper As Long
    ' Create InternetExplorer Object
    Set IE = New InternetExplorerMedium
    IE.Visible = True


    For looper = 2 To 97
    IE.navigate Cells(looper, 3).Value 'a list of URL's in column C
    'example is
    'https://www.priceline.com.au/brand/bvlgari/bvlgari-mon-jasmin-noir-edp-50-ml


    SideLooper = 0
    While IE.LocationURL <> Cells(looper, 3).Value
    DoEvents
    Application.Wait DateAdd("s", 1, Now)
    SideLooper = SideLooper + 1
    If SideLooper = 6 Then
    'have waited 6 seconds
    Cells(looper, 7).Value = Cells(looper, 3).Value
    Cells(looper, 3).Value = IE.LocationURL
    'this will get us out of a loop, storing the current and original URLS
    End If

    Wend
    On Error Resume Next
    dd = IE.document.getElementById("Price")(0).innerText
    Cells(looper, 5).Value = dd
    Cells(looper, 6).WrapText = False
    Cells(looper, 3).Activate
    dd = "999999"
    Next
    IE.Visible = True


    Set IE = Nothing


    Application.StatusBar = ""
    End Sub

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    This code works for me. I've highlighted the lines I changed
    Code:
    Private Sub PL_Scraper()
    'comes up with page cannot be displayed in IE
    Dim dd As String
    Dim prodID As String
    Dim IE As Object
    Dim looper As Long
    Dim retry As Long
    Dim SideLooper As Long
    ' Create InternetExplorer Object
    Set IE = CreateObject("InternetExplorer.Application")
    IE.Visible = True
    
    For looper = 2 To 97
      IE.navigate Cells(looper, 3).Value 'a list of URL's in column C
      'example is
      'https://www.priceline.com.au/brand/bvlgari/bvlgari-mon-jasmin-noir-edp-50-ml
      
      SideLooper = 0
      While IE.LocationURL <> Cells(looper, 3).Value
        DoEvents
        Application.Wait DateAdd("s", 1, Now)
        SideLooper = SideLooper + 1
        If SideLooper = 6 Then
        'have waited 6 seconds
        Cells(looper, 7).Value = Cells(looper, 3).Value
        Cells(looper, 3).Value = IE.LocationURL
        'this will get us out of a loop, storing the current and original URLS
        End If
      
      Wend
      On Error Resume Next
      dd = IE.document.getElementById("product-price-6822").innerText
      Cells(looper, 5).Value = dd
      Cells(looper, 6).WrapText = False
      Cells(looper, 3).Activate
      dd = "999999"
    Next
    IE.Visible = True
    Set IE = Nothing
    Application.StatusBar = ""
    End Sub
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. The Following User Says Thank You to Andrew Lockton For This Useful Post:

    aidan100 (2016-08-02)

  4. #3
    Lounger
    Join Date
    May 2003
    Posts
    29
    Thanks
    3
    Thanked 1 Time in 1 Post
    many thanks - it is currently still not working for me, however, the fact that it works for you suggests it MAY relate to security settings or similar - I'm at least happy that the code is OK so can dig further into the setting!

  5. #4
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    Is the element ID the same in all the pages you are navigating to? I could only test the one url you posted in your code.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •