View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Stuck at Trying to Extract Data from a Website using JSP

Here is code to get you started. I don't know chinese and not sure what
data you are looking for. I belive the ID=E0005 the part of the query that
extracts a particular house. Not sure how to lookup the id's. You can
create a string to get the URL like this:

----------------------------------------------------------------
ID = "E00005"

URL = "http://proptx.midland.com.hk/unit/index.jsp
Request = URL & "?est_id=" & ID
IE.Navigate2 URL
------------------------------------------------------------------
Below is code to dump the info from the house you had listed.


Sub GetHouse()

URL = "http://proptx.midland.com.hk/unit/index.jsp?est_id=E00005"


Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True


'get web page
IE.Navigate2 URL
Do While IE.readystate < 4 Or _
IE.Busy = True
DoEvents
Loop

'test code
'With Sheets("Sheet3")
' RowCount = 1
' For Each itm In IE.document.all
' .Range("A" & RowCount) = itm.tagname
' .Range("B" & RowCount) = itm.ID
' .Range("C" & RowCount) = itm.classname
' .Range("D" & RowCount) = Left(itm.innertext, 1024)

' RowCount = RowCount + 1
' Next itm
'End With




Set Table = IE.document.getElementsByTagname("Table")

RowCount = 1
For Each Row In Table(7).Rows
Colcount = 1
For Each cell In Row.Cells
Cells(RowCount, Colcount) = cell.innertext
Colcount = Colcount + 1
Next cell

RowCount = RowCount + 1
Next Row
End Sub



"HC" wrote:

Hello,

There is this page that lists out the past transaction records of houses:
http://proptx.midland.com.hk/unit/in...?est_id=E00005 (it's in Chinese)

If you click on a particular house, the past transaction records of that
house is shown.

I want to be able to extract the past transaction data and make charts to
visualise the price trend of the houses. Now, I'm only able to use the
"stupid" method of clicking on all the houses and typing in manually the
transaction records in Excel and then chart the data.

I wish to be able to extract the data to Excel automatically. I have
studied the underlying jsp pages and it seems that the site uses
http://proptx.midland.com.hk/unit/unit_tx.jsp to show the data.

I have tried typing in
http://proptx.midland.com.hk/unit/un..._id=U000146982 to see any
information will come up, but there's nothing in the page.

I'm totally stuck. As I want to monitor the trend of a number of
developments, it will be very tedious to type up all the transactions in
Excel. It seems the website has sort of exposed the data, but I just can't
find a way to get the data out, at least one house at a time.

I want to do webquery in Excel and then extract the data to a proper table.

Hope some experts can point me in the right direction.

Regards and thanks in advance,

HC