ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Read Content From A Website (https://www.excelbanter.com/excel-programming/389020-read-content-website.html)

Pramod Mehta[_2_]

Read Content From A Website
 
hi all,
i want to read the dynamic content of a website..
i.e.,
Open http://www.thebulliondesk.com/
in that website at the very top there is a table kind of thing showing
Prices for Gold Price and Silver Price.
i want to read the prices of gold and silver (dynamic prices)from that
website and use them in my application.
is it any way possible to do so, and if so can u plz guide me how to do it..

thanks for the help in advance.

i tried saving the page's content in a .txt fromat but those dynamic values
were not there in the .txt file.

Jan Karel Pieterse

Read Content From A Website
 
Hi Pramod,

Open http://www.thebulliondesk.com/
in that website at the very top there is a table kind of thing showing
Prices for Gold Price and Silver Price.
i want to read the prices of gold and silver (dynamic prices)from that
website and use them in my application.
is it any way possible to do so, and if so can u plz guide me how to do it..


Data, get external data, new web query is the way to go I guess.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com


Pramod Mehta[_2_]

Read Content From A Website
 
hi Jan,
i tried doing it.. it showed an error saying that :"the query does not
return any value"
i tried exporting the whole page into excel and as u can see in the web page
there are colums showinf bid-ask-(+/-)-LDN, but the cells do not show the
values or the bid and ask column, as i think they r dynamic values.
so is there any other possibility to read the data.

thanks 4 the reply JAN


"Jan Karel Pieterse" wrote:

Hi Pramod,

Open http://www.thebulliondesk.com/
in that website at the very top there is a table kind of thing showing
Prices for Gold Price and Silver Price.
i want to read the prices of gold and silver (dynamic prices)from that
website and use them in my application.
is it any way possible to do so, and if so can u plz guide me how to do it..


Data, get external data, new web query is the way to go I guess.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com
Member of:
Professional Office Developer Association
www.proofficedev.com



Dave Miller

Read Content From A Website
 
Pramod,

The code below worked for me:

Regards,
David Miller


Function GetPrices()
Dim ie As Object, _
l, J As Long, _
r As Range

Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate "http://www.thebulliondesk.com/" & _
"RHS_CHARTS.aspx?Chart=Fix"
Do Until .readystate = 4
DoEvents
Loop
With .document.all
For l = 0 To .Length
If .Item(l).classname = "td" Then
Set r = Range("A65536").End(xlUp).Offset(1, 0)
Select Case .Item(l).innertext
Case "Gold"
For J = 0 To 5
r.Offset(0, J).Value = .Item(l +
J).innertext
Next J
Case "Silver"
For J = 0 To 5
r.Offset(0, J).Value = .Item(l +
J).innertext
Next J
GoTo PricesExit
End Select
End If
Next
End With
End With
PricesExit:
Set r = Nothing
Set ie = Nothing
End Function


Pramod Mehta[_2_]

Read Content From A Website
 
HI Dave

the piece of code u provided i tried pating it in a module in a n excel
sheet and then in workbook_open i called that function, by which it opened
internet explorer and showed the webpage pointing in the code. but i want the
data in the excel sheet..

and am i going the right way in executing the following code provided by
you. else guide me throught the steps.

thanks
Pramod Mehta

"Dave Miller" wrote:

Pramod,

The code below worked for me:

Regards,
David Miller


Function GetPrices()
Dim ie As Object, _
l, J As Long, _
r As Range

Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = True
.navigate "http://www.thebulliondesk.com/" & _
"RHS_CHARTS.aspx?Chart=Fix"
Do Until .readystate = 4
DoEvents
Loop
With .document.all
For l = 0 To .Length
If .Item(l).classname = "td" Then
Set r = Range("A65536").End(xlUp).Offset(1, 0)
Select Case .Item(l).innertext
Case "Gold"
For J = 0 To 5
r.Offset(0, J).Value = .Item(l +
J).innertext
Next J
Case "Silver"
For J = 0 To 5
r.Offset(0, J).Value = .Item(l +
J).innertext
Next J
GoTo PricesExit
End Select
End If
Next
End With
End With
PricesExit:
Set r = Nothing
Set ie = Nothing
End Function




All times are GMT +1. The time now is 08:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com