Page 1 of 1 1
Topic Options
#206419 - 2012-12-09 02:19 AM Inconsistent Results using InternetExplorer.Application
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Using the InternetExplorer.Application object I was able to get the "real" user agent IE displays. The problem is the results are very inconsistent. Sometimes I get the user agent returned correctly, and other times it is blank.

 Code:
function GetIEUserAgent()
  dim $ie,$page
  $ie=createobject("InternetExplorer.Application")
  $ie.navigate("http://whatsmyuseragent.com/")
  while $ie.busy and $ie.readystate <> 4 loop
  if $ie.document
    $page=split($ie.document.documentelement.innerhtml,chr(10))
    for $i=0 to ubound($page)
      if instr($page[$i],"Your User Agent:</strong>")
        $GetIEUserAgent=trim(split(split($page[$i],"Your User Agent:</strong>")[1],"<")[0])
      endif
    next
  endif
  $ie.quit
endfunction


I also tried
 Code:
while $ie.busy and $ie.readystate <> 4 and @error=0 loop

but it didn't help.

When it fails, this is all it gets, instead of a full page of html that has the user agent in it:
 Code:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Whats My User Agent?</title>
<meta name="description" content="Check your web browser User Agent instantly, a
long with the full header, Forwarded IP (for proxy service), IP to Country Conve
rsion, HTTP Referer, HTTP_X_FORWARDED_FOR and more!!!">
<meta name="keywords" content="what is my user agent Web browser client header I
P Address HTTP_X_FORWARDED_FOR User agent string local identifier IP to Country
IP-to-Country IP2Country Conversion HTTP Referer HTTP Referrer">
<link href="favicon.ico" rel="shortcut icon">
<link href="Main.css" rel="stylesheet" type="text/css"></head>

Any ideas?
_________________________
(... better days ahead)

Top
#206421 - 2012-12-09 02:53 AM Re: Inconsistent Results using InternetExplorer.Application [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
server error seems to be.
the part generating the actual body of the html is most likely crashing.
_________________________
!

download KiXnet

Top
#206422 - 2012-12-09 03:54 AM Re: Inconsistent Results using InternetExplorer.Application [Re: Lonkero]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Here's how I got around it. It never needed more than a second try, but I set it to loop 5 times before it quits.

 Code:
function GetIEUserAgent()
  dim $ie,$page,$i,$j
  $ie=createobject("InternetExplorer.Application")
  while $GetIEUserAgent="" and $j<5
    $ie.navigate("http://whatsmyuseragent.com/")
    while $ie.busy and $ie.readystate <> 4 loop
    if $ie.document
      $page=split($ie.document.documentelement.innerhtml,chr(10))
      for $i=0 to ubound($page)
        if instr($page[$i],"Your User Agent:</strong>")
          $GetIEUserAgent=trim(split(split($page[$i],"Your User Agent:</strong>")[1],"<")[0])
        endif
      next
    endif
    $j=$j+1
  loop
  $ie.quit
endfunction
_________________________
(... better days ahead)

Top
#207119 - 2013-04-18 08:23 PM Re: Inconsistent Results using InternetExplorer.Application [Re: Allen]
Allen Administrator Offline
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4574
Loc: USA
Seems the whatsmyuseragent.com updated their page, and broke the udf above. Here's a newer version.

 Code:
function GetIEUserAgent()
  dim $ie,$page,$i,$j
  $ie=createobject("InternetExplorer.Application")
  while $GetIEUserAgent="" and $j<5
    $ie.navigate("http://whatsmyuseragent.com/")
    while $ie.busy and $ie.readystate <> 4 loop
    if $ie.document
      $page=split($ie.document.documentelement.innerhtml,chr(10))
      for $i=0 to ubound($page)
        if instr($page[$i],'id="body_lbUserAgent">')
          $GetIEUserAgent=trim(split(split($page[$i],'id="body_lbUserAgent">')[1],"<")[0])
        endif
      next
    endif
    $j=$j+1
  loop
  $ie.quit
endfunction
_________________________
(... better days ahead)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.051 seconds in which 0.025 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org