Im trying to perform a screen scrape because i can't find a relevant free API to get the data i need. I've managed to perform the scrape and grab the HTML page but the part i'm stuck on is getting the relevant information out of the grabbed content. I'm guessing i will need to use REG expressions to search through the HTML but unsure how to do this. the information I'm after is MAKE, MODEL, YEAR of the current car search.
var url = NSURL(string: "https://www.rac.co.uk/buying-a-car/car-passport/report/buyer/purchase/?BuyerVrm=yg06dxt")
if url != nil {
let task = NSURLSession.sharedSession().dataTaskWithURL(url!, completionHandler: { (data, response, error) -> Void in
print(data)
if error == nil {
var urlContent = NSString(data: data, encoding: NSASCIIStringEncoding) as NSString!
print(urlContent)
}
})
task.resume()
}
}
heres a sample of the retuned information
<p class="CarMiniProfile-caveat u-hidden">*image for illustrative purposes only</p>
<div>
<table class="CarMiniProfile-table">
<tbody>
<tr class="CarMiniProfile-tableFirstRow">
<td class="CarMiniProfile-tableHeader">
Make
</td>
<td>
FIAT
</td>
</tr>
<tr>
<td class="CarMiniProfile-tableHeader">
Model
</td>
<td>
PUNTO SPORTING M-JET
</td>
</tr>
<tr>
<td class="CarMiniProfile-tableHeader">
Colour
</td>
<td>
BLUE
</td>
</tr>
<tr>
<td class="CarMiniProfile-tableHeader">
Year
</td>
<td>
2006
</td>
</tr>
<tr>
<td class="CarMiniProfile-tableHeader">
Engine Size
</td>
<td>
1910 cc
</td>
</tr>
</tbody>
</table>
</div>
<h3 class="CarMiniProfile-subheading">Check this car in 3 simple steps...</h3>