Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel formula to change page # when data entered in other page | Excel Discussion (Misc queries) | |||
How do I copy a graph of a data page to a new data page. | Charts and Charting in Excel | |||
Page Break Preview Page Number as Data | Excel Programming | |||
excel fit to 1 page shows 1 page but not all data is on that page | Excel Programming | |||
Printing second page if data overruns, otherwise print first page | Excel Programming |