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 page


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: 21
Default Data from web page

I'm not exactly sure of your intention or usage, but if it is just to
retrieve some data from a web page and display it in some range on a
worksheet then the following code should do the trick ...

--------------------
Sub Create_Web_QueryTables()
Dim strCnn As String
' Insert the full URL desired. For example as below ...
strCnn =
"URL;http://investing.reuters.co.uk/Stocks/Quote.aspx?symbol=RTR.L"
With ActiveSheet.QueryTables.Add(Connection:=strCnn,
Destination:=Range("A1"))
.Name = "WebQueryTest"
.QueryType = xlWebQuery ' Based on a Web page
.RefreshStyle = xlInsertEntireRows
.HasAutoFormat = False
.WebFormatting = xlWebFormattingNone
' We want to specify particular tables, otherwise could use
xlAllTables (default)
.WebSelectionType = xlSpecifiedTables
' Define the tables on this page to import
.WebTables = "25"
.RefreshOnFileOpen = True
.Refresh
End With
End Sub
--------------------

HTH, Sean.

"spaceman33" wrote:


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: 21
Default Data from web page

Sorry, got a bit tangled up with my copy/paste and pressed the post button
too quickly.

The line of code after ".Name = ..." is just a comment and should read as
follows ...

' Based on a web page: .QueryType = xlWebQuery.

Apologies, Sean.

"Sean Connolly" wrote:

I'm not exactly sure of your intention or usage, but if it is just to
retrieve some data from a web page and display it in some range on a
worksheet then the following code should do the trick ...

--------------------
Sub Create_Web_QueryTables()
Dim strCnn As String
' Insert the full URL desired. For example as below ...
strCnn =
"URL;http://investing.reuters.co.uk/Stocks/Quote.aspx?symbol=RTR.L"
With ActiveSheet.QueryTables.Add(Connection:=strCnn,
Destination:=Range("A1"))
.Name = "WebQueryTest"
.QueryType = xlWebQuery ' Based on a Web page
.RefreshStyle = xlInsertEntireRows
.HasAutoFormat = False
.WebFormatting = xlWebFormattingNone
' We want to specify particular tables, otherwise could use
xlAllTables (default)
.WebSelectionType = xlSpecifiedTables
' Define the tables on this page to import
.WebTables = "25"
.RefreshOnFileOpen = True
.Refresh
End With
End Sub
--------------------

HTH, Sean.

"spaceman33" wrote:


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: 2
Default Data from web page

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.

*** Sent via Developersdex http://www.developersdex.com ***
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
Excel formula to change page # when data entered in other page Solograndma Excel Discussion (Misc queries) 2 March 12th 07 01:35 PM
How do I copy a graph of a data page to a new data page. Jackrc Charts and Charting in Excel 1 May 9th 06 12:20 PM
Page Break Preview Page Number as Data Neal Zimm Excel Programming 1 May 3rd 05 01:01 AM
excel fit to 1 page shows 1 page but not all data is on that page Jans Excel Programming 1 September 2nd 04 01:49 AM
Printing second page if data overruns, otherwise print first page playdohstu Excel Programming 1 February 12th 04 02:08 PM


All times are GMT +1. The time now is 10:17 AM.

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"