Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Data from web site

I am trying to get some data from a web site.

Because the data is part of a table on a web site, not the main table, I think that's why I can't find it.

Code similar to what I am trying is:

a = ""
url = link
Dim IE As Object
'this part open explorer and navigates to the web site I want
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = False
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'I would then search for the text preceeding the value I am looking for
Position = InStr(1, a, "Enemy Kills:", vbTextCompare)


Like I said, I think because the text is in another section of the web page it doesn't find it.

Some data I found from the Source of the web site is:

<table id="member-jacket" class="info info-member" cellspacing="1"

I am hoping this will help find the solution.

Thanks in advance for any thoughts.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Data from web site

why not post the url?

Tim


"spaceman33" wrote in message
...
I am trying to get some data from a web site.

Because the data is part of a table on a web site, not the main table,
I think that's why I can't find it.

Code similar to what I am trying is:

a = ""
url = link
Dim IE As Object
'this part open explorer and navigates to the web site I want
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = False
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'I would then search for the text preceeding the value I am looking
for
Position = InStr(1, a, "Enemy Kills:", vbTextCompare)


Like I said, I think because the text is in another section of the web
page it doesn't find it.

Some data I found from the Source of the web site is:

<table id="member-jacket" class="info info-member" cellspacing="1"

I am hoping this will help find the solution.

Thanks in advance for any thoughts.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Data from web site


Yep, posted it in the original thread:

Thanks for the info.

I found the code I had previously used:
================================================== =======
Sub Button4_Click()
'AA
a = ""
url = "http://login.americasarmy.com/views/login.php"
'Const url As String = link
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = True
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'enter login details
IE.document.all("username").Value = "username"
IE.document.all("password").Value = "password"
With IE.document.Forms(0)
.submit.Click
End With
'get score

#####THIS NEXT PART IS WHERE I WANT TO DO THE SEARCHING FOR THE STRING
Experience Required for Next Level#####

Position = InStr(1, a, "Experience Required for Next Level",
vbTextCompare)
honour = ""
For z = 13 To 25
If Asc(Mid$(a, Position + z, 1)) = 13 Then z = 25: GoTo 599
honour = honour & Mid$(a, Position + z, 1)
599
Next z
MsgBox honour
Set IE = Nothing
End Sub
================================================== ========

How would I put that code into the above? I am already at the web site
page I want to grab the information from, I just need to get the
information from a section of the web page (different table or whatever
it is).

Thanks.

"Tim Williams" <saxifrax@pacbell*dot*net wrote in message
...

why not post the url?

Tim


"spaceman33" wrote in message
...
I am trying to get some data from a web site.

Because the data is part of a table on a web site, not the main table, I
think that's why I can't find it.

Code similar to what I am trying is:

a = ""
url = link
Dim IE As Object
'this part open explorer and navigates to the web site I want
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = False
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'I would then search for the text preceeding the value I am looking for
Position = InStr(1, a, "Enemy Kills:", vbTextCompare)


Like I said, I think because the text is in another section of the web
page it doesn't find it.

Some data I found from the Source of the web site is:

<table id="member-jacket" class="info info-member" cellspacing="1"

I am hoping this will help find the solution.

Thanks in advance for any thoughts.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Data from web site

If your browser already has the page loaded then you can skip all of
the navigate and login code.
Try the function below (GetPageText) - it will return the text from a
page loaded in IE which matches the passed URL parameter. This
assumes that the page does not use frames - if it does then you'll
have to include a reference to which frame you want.

You can then parse out the info from the returned string. I can't
help much with that, not having seem the text you need to separate.

Tim.



Sub tester()
MsgBox GetPageText("http://login.americasarmy.com/views/login.php")
End Sub

'Find an IE window with matching location and get the Text from
' the loaded page. Assumes no frames.
Function GetPageText(sAddress As String) As String

Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As String, sURL As String


retVal = ""
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows

'see if IE is already open
For Each o In objShellWindows
sURL = ""
On Error Resume Next
sURL = o.Document.Location
On Error GoTo 0
If sURL < "" Then
If sURL Like sAddress & "*" Then
retVal = o.Document.body.innerText
Exit For
End If
End If
Next o

GetPageText = retVal
End Function





"spaceman33" wrote in message
...

Yep, posted it in the original thread:

Thanks for the info.

I found the code I had previously used:
================================================== =======
Sub Button4_Click()
'AA
a = ""
url = "http://login.americasarmy.com/views/login.php"
'Const url As String = link
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = True
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'enter login details
IE.document.all("username").Value = "username"
IE.document.all("password").Value = "password"
With IE.document.Forms(0)
.submit.Click
End With
'get score

#####THIS NEXT PART IS WHERE I WANT TO DO THE SEARCHING FOR THE
STRING
Experience Required for Next Level#####

Position = InStr(1, a, "Experience Required for Next Level",
vbTextCompare)
honour = ""
For z = 13 To 25
If Asc(Mid$(a, Position + z, 1)) = 13 Then z = 25: GoTo 599
honour = honour & Mid$(a, Position + z, 1)
599
Next z
MsgBox honour
Set IE = Nothing
End Sub
================================================== ========

How would I put that code into the above? I am already at the web
site
page I want to grab the information from, I just need to get the
information from a section of the web page (different table or
whatever
it is).

Thanks.

"Tim Williams" <saxifrax@pacbell*dot*net wrote in message
...

why not post the url?

Tim


"spaceman33" wrote in message
...
I am trying to get some data from a web site.

Because the data is part of a table on a web site, not the main
table, I think that's why I can't find it.

Code similar to what I am trying is:

a = ""
url = link
Dim IE As Object
'this part open explorer and navigates to the web site I want
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = False
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'I would then search for the text preceeding the value I am looking
for
Position = InStr(1, a, "Enemy Kills:", vbTextCompare)


Like I said, I think because the text is in another section of the
web page it doesn't find it.

Some data I found from the Source of the web site is:

<table id="member-jacket" class="info info-member" cellspacing="1"

I am hoping this will help find the solution.

Thanks in advance for any thoughts.







  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Data from web site


Frames, that's the word I was looking for.

I think I need to select the frame with the ID <table id="member-jacket"
class="info info-member" cellspacing="1", but don't know how to select it
to get the text from there.

I'm not clued up on HTML, but hopefully that is the name of the frame I want
to grab info from?

"Tim Williams" <saxifrax@pacbell*dot*net wrote in message
...

If your browser already has the page loaded then you can skip all of the
navigate and login code.
Try the function below (GetPageText) - it will return the text from a page
loaded in IE which matches the passed URL parameter. This assumes that
the page does not use frames - if it does then you'll have to include a
reference to which frame you want.

You can then parse out the info from the returned string. I can't help
much with that, not having seem the text you need to separate.

Tim.



Sub tester()
MsgBox GetPageText("http://login.americasarmy.com/views/login.php")
End Sub

'Find an IE window with matching location and get the Text from
' the loaded page. Assumes no frames.
Function GetPageText(sAddress As String) As String

Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As String, sURL As String


retVal = ""
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows

'see if IE is already open
For Each o In objShellWindows
sURL = ""
On Error Resume Next
sURL = o.Document.Location
On Error GoTo 0
If sURL < "" Then
If sURL Like sAddress & "*" Then
retVal = o.Document.body.innerText
Exit For
End If
End If
Next o

GetPageText = retVal
End Function





"spaceman33" wrote in message
...

Yep, posted it in the original thread:

Thanks for the info.

I found the code I had previously used:
================================================== =======
Sub Button4_Click()
'AA
a = ""
url = "http://login.americasarmy.com/views/login.php"
'Const url As String = link
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = True
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'enter login details
IE.document.all("username").Value = "username"
IE.document.all("password").Value = "password"
With IE.document.Forms(0)
.submit.Click
End With
'get score

#####THIS NEXT PART IS WHERE I WANT TO DO THE SEARCHING FOR THE STRING
Experience Required for Next Level#####

Position = InStr(1, a, "Experience Required for Next Level",
vbTextCompare)
honour = ""
For z = 13 To 25
If Asc(Mid$(a, Position + z, 1)) = 13 Then z = 25: GoTo 599
honour = honour & Mid$(a, Position + z, 1)
599
Next z
MsgBox honour
Set IE = Nothing
End Sub
================================================== ========

How would I put that code into the above? I am already at the web site
page I want to grab the information from, I just need to get the
information from a section of the web page (different table or whatever
it is).

Thanks.

"Tim Williams" <saxifrax@pacbell*dot*net wrote in message
...

why not post the url?

Tim


"spaceman33" wrote in message
...
I am trying to get some data from a web site.

Because the data is part of a table on a web site, not the main table, I
think that's why I can't find it.

Code similar to what I am trying is:

a = ""
url = link
Dim IE As Object
'this part open explorer and navigates to the web site I want
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = False
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'I would then search for the text preceeding the value I am looking for
Position = InStr(1, a, "Enemy Kills:", vbTextCompare)


Like I said, I think because the text is in another section of the web
page it doesn't find it.

Some data I found from the Source of the web site is:

<table id="member-jacket" class="info info-member" cellspacing="1"

I am hoping this will help find the solution.

Thanks in advance for any thoughts.













  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Data from web site


That's a table, not a frame.

Try replacing

retVal = o.Document.body.innerText

with

retVal =
o.Document.getElementById("member-jacket").rows[0].cells[0].innerText

(watch out for wrapping)

This will get you the first cell in the table - adjust to (eg.)
"rows[3].cells[4]" to get the text you want.

That should get you closer
Tim.

"spaceman33" wrote in message
...

Frames, that's the word I was looking for.

I think I need to select the frame with the ID <table
id="member-jacket" class="info info-member" cellspacing="1", but
don't know how to select it to get the text from there.

I'm not clued up on HTML, but hopefully that is the name of the
frame I want to grab info from?

"Tim Williams" <saxifrax@pacbell*dot*net wrote in message
...

If your browser already has the page loaded then you can skip all
of the navigate and login code.
Try the function below (GetPageText) - it will return the text from
a page loaded in IE which matches the passed URL parameter. This
assumes that the page does not use frames - if it does then you'll
have to include a reference to which frame you want.

You can then parse out the info from the returned string. I can't
help much with that, not having seem the text you need to separate.

Tim.



Sub tester()
MsgBox
GetPageText("http://login.americasarmy.com/views/login.php")
End Sub

'Find an IE window with matching location and get the Text from
' the loaded page. Assumes no frames.
Function GetPageText(sAddress As String) As String

Dim objShell As Object, objShellWindows As Object, o As Object
Dim retVal As String, sURL As String


retVal = ""
Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows

'see if IE is already open
For Each o In objShellWindows
sURL = ""
On Error Resume Next
sURL = o.Document.Location
On Error GoTo 0
If sURL < "" Then
If sURL Like sAddress & "*" Then
retVal = o.Document.body.innerText
Exit For
End If
End If
Next o

GetPageText = retVal
End Function





"spaceman33" wrote in message
...

Yep, posted it in the original thread:

Thanks for the info.

I found the code I had previously used:
================================================== =======
Sub Button4_Click()
'AA
a = ""
url = "http://login.americasarmy.com/views/login.php"
'Const url As String = link
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = True
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'enter login details
IE.document.all("username").Value = "username"
IE.document.all("password").Value = "password"
With IE.document.Forms(0)
.submit.Click
End With
'get score

#####THIS NEXT PART IS WHERE I WANT TO DO THE SEARCHING FOR THE
STRING
Experience Required for Next Level#####

Position = InStr(1, a, "Experience Required for Next Level",
vbTextCompare)
honour = ""
For z = 13 To 25
If Asc(Mid$(a, Position + z, 1)) = 13 Then z = 25: GoTo 599
honour = honour & Mid$(a, Position + z, 1)
599
Next z
MsgBox honour
Set IE = Nothing
End Sub
================================================== ========

How would I put that code into the above? I am already at the web
site
page I want to grab the information from, I just need to get the
information from a section of the web page (different table or
whatever
it is).

Thanks.

"Tim Williams" <saxifrax@pacbell*dot*net wrote in message
...

why not post the url?

Tim


"spaceman33" wrote in message
...
I am trying to get some data from a web site.

Because the data is part of a table on a web site, not the main
table, I think that's why I can't find it.

Code similar to what I am trying is:

a = ""
url = link
Dim IE As Object
'this part open explorer and navigates to the web site I want
Set IE = CreateObject("internetexplorer.application")
With IE
.Visible = False
.navigate url
Do While .ReadyState < 4: Loop
a = .document.body.innertext
End With
'I would then search for the text preceeding the value I am
looking for
Position = InStr(1, a, "Enemy Kills:", vbTextCompare)


Like I said, I think because the text is in another section of
the web page it doesn't find it.

Some data I found from the Source of the web site is:

<table id="member-jacket" class="info info-member"
cellspacing="1"

I am hoping this will help find the solution.

Thanks in advance for any thoughts.













Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
importing data into excel2003 from some web site? alan Excel Discussion (Misc queries) 1 December 24th 07 09:40 AM
Importing Web Site Data Vernon Balbert New Users to Excel 0 November 9th 07 03:54 PM
How do I retrieve data into a cell from a web site? Matty Excel Worksheet Functions 0 May 9th 05 03:43 PM
Getting data from web site to excel Dusan Excel Programming 4 December 18th 03 09:08 PM
accessing data on a web site milt Excel Programming 1 December 11th 03 08:14 PM


All times are GMT +1. The time now is 01:27 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"