Answer the question
In order to leave comments, you need to log in
Parsing with Google SpreadSheets. Where is the mistake?
What do you need to pass to start and end to parse the dollar rate from this page( cbr.ru/currency_base/daily.aspx?date_req=08/06/2017)?
HTML code of the page (so you don't have to climb):
<tr><td>840</td>
<td>USD</td>
<td>1</td>
<td>Доллар США</td>
<td>60,3281</td></tr>
function getConten(){
getPageContent("http://cbr.ru/currency_base/daily.aspx?date_req=06.08.2017");
}
function getPageContent(url) {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B1");
var cell = range.getCell(1,1);
var response = UrlFetchApp.fetch(url);
var textResp = response.getContentText();
var start, end, name;
var i;
for(i = 0; i < 10; i++){
start = textResp.indexOf('США</td><td>', end);
end = textResp.indexOf('</td>', start);
name = textResp.substring(start, end);
cell.setValue(name);
cell = cell.offset(1, 0);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question