I do price parsing with this function:
function myFunction (pos, url) { var sheet = SpreadsheetApp.getActiveSheet(); var range = sheet.getRange(pos); var cell = range.getCell(1,1); try { var response = UrlFetchApp.fetch(url); var textResp = response.getContentText(); var start, end, value; start = textResp.indexOf('"price":"', end) + 9; end = textResp.indexOf('.00","list"', start); name = textResp.substring(start, end); cell.setValue(name); cell = cell.offset(0,1); start = textResp.indexOf('item_avb availability_', end) + 22; end = textResp.indexOf('"><link itemprop', start); value = textResp.substring(start, end); if (value == 'yes') cell.setValue('есть') else cell.setValue('на заказ') } catch (err) { cell.setValue('404!!!'); } } Reference sheet = SpreadsheetApp.getActiveSheet()
And how will you turn to the sheet of the document not from which you went to the editor, but by name? There are several sheets in the document and sometimes the script overwrites me with not the right thing ...
And through try catch , processing is implemented if the URL is not accessible, but somehow it looks clumsy. Can someone tell me how poetic?