Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ESPN_GOLF(){
- const response = UrlFetchApp.fetch('https://site.web.api.espn.com/apis/v2/scoreboard/header?sport=golf&league=pga®ion=us&lang=en&contentorigin=espn')
- const data = JSON.parse(response.getContentText())
- const output = []
- data.sports[0].leagues[0].events[0].competitors.forEach((c, i) => {
- const object = {
- place: c.place,
- winner: c.winner,
- name: c.displayName,
- firstname: c.firstName,
- lastname: c.lastName,
- shortname: c.shortName,
- amount: c.amount,
- officialAmount: c.officialAmount,
- earnings: c.earnings,
- score: c.score,
- movement: c.movement,
- status_period: c.status.period,
- status_teeTime: c.status.displayValue,
- status_hole: c.status.hole,
- status_startHole: c.status.startHole,
- status_thru: c.status.thru,
- status_playoff: c.status.playoff,
- status_state: c.status.state,
- photo: c.headshot
- }
- if (i == 0){
- output.push(Object.keys(object))
- }
- output.push(Object.values(object))
- })
- return output
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement