Capture property details from a real estate website

The script below opens a real estate website, types some criteria and captures information for each property listed.

You can find the corresponding script file under Script_Examples, sub-directory of scripts.

 

'Declaration of the arrays needed for storing the captured data

Dim Price$(1000)

Dim Description$(1000)

 

Sub capture_details(index)

'This Sub captures the details for one property

'and stores the captured data in the different arrays at row defined by index parameter.
UsePage("fish4 homes - property, flats and houses for sale")
'Using Spy, we capture the town and price for this property.

'As HTML descriptor uses the town, we change it using only the £ sign

'which will be there for any property.
CaptureHTML("H1[CONTENT='£']", var$)

'var$ returns the captured data.

'We store it in Price$(index)

Price$(index)=var$

 

'We capture then Property description

'Again we change the HTML descriptor given by Spy to take the full sentence

'Property description
UsePage("fish4 homes - property, flats and houses for sale")
CaptureHTML("DIV[CONTENT='Property description']", var$)

'We store the captured data in Description$(index)

Description$(index)=var$

EndSub

 

'Criteria definition for selecting the properties to search for.

minPrice$="£70,000"

maxPrice$="£90,000"

location$="Merseyside"

bedroom$="At least One"

 

'As the website has long response times, we increase the delay before reporting that a page is not loaded
'from the default 30 secs to 60 secs.
#ActionTimeout=60

 
StartBrowser("ie","http://www.fish4.co.uk/homes/",3)

 

UsePage("fish4 homes - property, flats and houses for sale")

WriteHTML("INPUT TEXT[NAME= 'location']", location$)

SelectHTMLItem("SELECT[NAME= 'pricelow']", minPrice$)

SelectHTMLItem("SELECT[NAME= 'pricehigh']", maxPrice$)

SelectHTMLItem("SELECT[NAME= 'numberOfBedrooms']", bedroom$)

ClickHTMLElement("INPUT SUBMIT[NAME= 'search']")

 

'List of properties is displayed.

'We click More details on each property for the first 10 displayed

'HTML descriptor for More details is

'"A[INNERTEXT= 'More details']" for the first property

'"A[INNERTEXT= 'More details',INDEX='2']" for the second property and so on

'So we do a loop based on that index number

i=1

repeat

UsePage("fish4 homes")

ClickHTMLElement("A[INNERTEXT= 'More details',INDEX='"+str$(i)+"']")

'capture the details here on the next page

'This capture is done using a Sub, Sub declared at the beginning of the script

'The Sub is called capture_details ; we use as index i-1 because arrays start at index 0

capture_details(i-1)

'come back to the previous page pressing backspace key

pause 1

usewindow(top$())

sendkeys("<BackSpace>",NoActivate)

i=i+1

until i=11

 

'Write the results in an Excel file

excelfile$="c:\wttest\property.xlsx"

 

CreateExcelFile(excelfile$)

WriteExcel(excelfile$,"A1:A10",price$())

WriteExcel(excelfile$,"B1:B10",description$())

 

'Close all IE windows

KillApp("IEXPLORE.EXE",1)

 

Open the Excel spreadsheet, you will see in columns A and B the captured data. They are not nicely formatted, you can format the cells in Excel. The script above does not display all the properties as it does not click Next button, you can enhance the script to make it click Next button if such a button is on the page.