Script to show upcoming U2 concerts

My favourite band’s site doesn’t have a JSON file (check them out, they’re great!) so I had to work directly on the HTML. Here’s a screenshot and the code I wrote based on what @rob shared here, so thank you for the guidance! Also, thank you @simonbs for creating such a cool app! I’m looking forward to playing around with it even more.

// Gets page url
let url = "http://www.berritxarrak.net/kontzertuak/"
let req = new Request(url)
let html = await req.load()

// Starts table
let table = new UITable()

// Gets html with concert info
let infoStart = html.indexOf('event type-event status-publish hentry active no-media')
let infoEnd = html.indexOf('</section>',infoStart+1)

let finishSearch = html.indexOf('<!-- .main-content end -->')

while(infoStart < finishSearch){

let concertInfoHTML = html.substring(infoStart,infoEnd)

// Gets concert day
let dayStart = concertInfoHTML.indexOf('<strong>')
let dayEnd = concertInfoHTML.indexOf('</strong>')
let day = concertInfoHTML.substring(dayStart+8,dayEnd)

// Gets concert month
let monthStart = concertInfoHTML.indexOf('<span class="month">')
let monthEnd = concertInfoHTML.indexOf('</span>')
let month = concertInfoHTML.substring(monthStart+20,monthEnd)

// Gets concert day of the week
let weekdayStart = concertInfoHTML.indexOf('<span class="day-name">')
let weekdayEnd = concertInfoHTML.indexOf('</span>',weekdayStart+1)
let weekday = concertInfoHTML.substring(weekdayStart+23,weekdayEnd)

// Gets concert city
let cityStart = concertInfoHTML.indexOf('/">')
let cityEnd = concertInfoHTML.indexOf('</a></h1>',cityStart+1)
let city = concertInfoHTML.substring(cityStart+3,cityEnd)
city = city.charAt(0) + city.slice(1).toLowerCase()

// Gets concert time
let timeStart = concertInfoHTML.indexOf('<span class="event-time-text"> <i class="icon-time"></i>')
let timeEnd = concertInfoHTML.indexOf('</span>',timeStart+1)
let time = concertInfoHTML.substring(timeStart+56,timeEnd)

// Adds emojis to strings
let date = '🗓 ' + month + ' ' + day
city = '🏙 ' + city
time = '🕘 ' + time

// Creates row inside the table
let row = new UITableRow()

let timeCell = UITableCell.text(time)
timeCell.leftAligned()
timeCell.widthWeight = 2
row.addCell(timeCell)

let dateCell = UITableCell.text(date)
dateCell.leftAligned()
dateCell.widthWeight = 2
row.addCell(dateCell)

// let weekdayCell = UITableCell.text(weekday)
// weekdayCell.leftAligned()
// row.addCell(weekdayCell)

let cityCell = UITableCell.text(city)
cityCell.leftAligned()
cityCell.widthWeight = 5
row.addCell(cityCell)

row.height = 40
row.cellSpacing = 1
table.addRow(row)

// Gets html with concert info
infoStart = html.indexOf('event type-event status-publish hentry active no-media', infoEnd+1)

infoEnd = html.indexOf('</section>',infoStart+1)
}

if (config.runsWithSiri) {
  Speech.speak("Here's the coming Berri Txarrak concerts.")
}

QuickLook.present(table)
1 Like