I need help making this script that would pull the prices off a website and log it into spreadsheets with a date and timestamp, this was:
function pullPrices() {
var page = UrlFetchApp.fetch('http://www.apbcc.com').getContentText();
var number = page.match(/Soya (X Nagpur): ([0-9,]+)/)[1];
SpreadsheetApp.getActive().getSheetByName('Sheet1').appendRow([new Date(), number]);
}
Basically in the webpage they list the prices for maize and soya and I wanted to log it every 5minutes
The output should look like 1/1/2013 11.53 12.50 ( for maize nd soya respectively) However, the script is throwing error upon execution. Could someone please throw some light.
Thanks Harold. Appreciate your prompt response, However the code works fine if it is fed with the text, but if it has to fetch the html content using UrlFetchApp.fetch('http://www.apbcc.com').getContentText(); it doesn't work. Also, in the content that is fetched, the prices are in the next line of the parameters as shown below
<div style="font-size:14px;">
Soya (X Nagpur):
32.20</br>
Maize (WGL):
11.50</br>
Rice Bran Oil (Hyd):
51</br>
Maize (NZB):
11.30</br>
DCP:
29</br>
As on 03/02/2014:
.</br>
Any suggestions ??