none
Getting Unspecified error 80004005

    Question

  • Hi,

    I have a script which successfully search a webpage for a keyword
    But the problem is when i search the same keyword from a list of webpages. I do this in loop..... read a website from txt file... navigate to it... and search for a keyword.. Next
    Below is the code for the same.

    Set WshShell = WScript.CreateObject("WScript.Shell")
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set listFile = fso.OpenTextFile("links.txt", ForReading)
    Const ForReading = 1

    Set ie = WScript.CreateObject("InternetExplorer.Application")
    ie.Visible = 1

    Do Until listFile.AtEndOfStream
    site = listFile.ReadLine()
    ie.Navigate2 site, &h800

    DO WHILE ie.busy
    wscript.sleep 100
    LOOP
    Find "user",site

    Loop
    WSCript.Quit

    Function Find(StrString,URL)
    WScript.Echo "Hello2"
    x = ie.document.documentElement.innertext 
    Set ie = Nothing
    Set objRegex = new RegExp
    objRegex.Pattern = StrString
    objRegex.Global = False
    objRegex.IgnoreCase = True
    Set Matches = objRegex.Execute(x)

    If Matches.Count>0 Then 
    WScript.Echo "Hello"
    Else

    WScript.Echo "Hello1"
    End If
    End Function

    I'm getting a error at line 23 "x = ie.document.documentElement.innertext" saying unspecifed error 80004005. I can confirm that the flow of script is coming till line 22

    Please help me out here.... i'm stuck here completely with no progress from last 3-4 days.

    thanks
    Monday, May 06, 2013 8:50 AM

Answers

All replies

  • check here for that error

    http://www.computerperformance.co.uk/Logon/code/code_80004005.htm#The Causes of Code 80004005


    MK

    Monday, May 06, 2013 1:28 PM
  • In this case the 'Access Denied' in on IE.  The IE instance has the property locked for an of another reason.  Access to an HTTPS site can cause this.  It can also be caused because the page is being refreshed.  Many pages will refresh repeatedly which will make the page seem to be always busy.  This is done sometimes to prevent screen scraping like you are trying to do.  It can also be cased by a badly designed web page or by a browser that has issues.

    PowerShell handles this much better because it can capture the page even if the page is refreshing.


    ¯\_(ツ)_/¯

    Monday, May 06, 2013 3:00 PM
  • Here is how to do it in PowerShell.

    Use this against site that has issues to see if it fixes your problem.

    $wc=New-Object System.Net.WebClient
    $wc.DownloadString('http://www.google.com') | Select-String -SimpleMatch 'google'

    Replace URL and 'google' with your values.


    ¯\_(ツ)_/¯

    Monday, May 06, 2013 3:09 PM
  • Thank you all for quick response.

    But what i don't understand here is when i run my above script with single site, its runs perfectly. I having a hard time in figuring out what is happening when i running the above script in loop.

    Below is the code for searching keyword from a webpage which is running perfectly.

    'code to halt internet explorer

    Sub WaitForLoad(obj)
    Do While ie.Busy: Loop
    wscript.sleep(1000)
    End Sub

    Set ie = WScript.CreateObject("InternetExplorer.Application")
      ie.Visible = 1
    ie.Navigate("https://webmail2.wipro.com/")

    WaitForLoad(ie)
    Set WshShell = WScript.CreateObject("WScript.Shell")

    Data = ie.document.documentElement.innertext 
    Set ie = Nothing
    Set objRegex = new RegExp
    objRegex.Pattern = "User"
    objRegex.Global = False
    objRegex.IgnoreCase = True
    Set Matches = objRegex.Execute(Data)
     
    If Matches.Count>0 Then  
    WScript.Echo "Hello"


    Else

    WScript.Echo "Hello1"
    End If

    The only difference between my above code and this code is that in my above code i am searching for the keyword from multiple sites.

    Please suggest...

    Thanks

    Monday, May 06, 2013 3:58 PM