Created
March 26, 2021 02:35
-
-
Save moniquelive/a3b231365c7c21a927f4b2114264fd1d to your computer and use it in GitHub Desktop.
Google Sheets App Script to retrieve github jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fetchGHData_(description) { | |
const url = "https://jobs.github.com/positions.json?description=" + description; | |
const response = UrlFetchApp.fetch(url, { 'muteHttpExceptions': true }); | |
const json = response.getContentText(); | |
return JSON.parse(json); | |
} | |
function fillInTheBlanks() { | |
const TITLE_COLUMN = 0; | |
const COMPANY_COLUMN = 1; | |
const LOCATION_COLUMN = 2; | |
const COMPANY_LOGO_COLUMN = 3; | |
const dataRange = SpreadsheetApp.getActiveSpreadsheet().getRange("A:D"); | |
const ghValues = dataRange.getValues(); | |
var ui = SpreadsheetApp.getUi(); | |
var description = ui.prompt("Digite uma palavra da descrição do anuncio"); | |
const ghData = fetchGHData_(description.getResponseText()); | |
for (let row = 0; row < ghData.length; row++) { | |
const url = ghData[row].company_logo; | |
ghValues[row][TITLE_COLUMN] = ghData[row].title; | |
ghValues[row][COMPANY_COLUMN] = ghData[row].company; | |
ghValues[row][LOCATION_COLUMN] = ghData[row].location; | |
ghValues[row][COMPANY_LOGO_COLUMN] = `=IMAGE("${url}")`; | |
} | |
dataRange.setValues(ghValues); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment