Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is an API needed? #17

Open
TheOriginalSoni opened this issue Feb 24, 2024 · 1 comment
Open

Is an API needed? #17

TheOriginalSoni opened this issue Feb 24, 2024 · 1 comment

Comments

@TheOriginalSoni
Copy link
Contributor

No description provided.

@TheOriginalSoni
Copy link
Contributor Author

I'll collect all different codebases I know of that currently auto-query Nutrimatic in some way.

GScripts/JS

/**
 * Gets results from nutrimatic.org.
 */
function fetchResultsFromNutrimatic(queryText, maxResults) {
  if (maxResults == undefined) {
    maxResults = 10;
  }
  var result_re = />([ a-z]+)<\/span><br>$/;
  var uriSafeQueryText = encodeURIComponent(queryText)
  var response = UrlFetchApp.fetch("https://nutrimatic.org/?src=googledoc-puzzle-tools&q="+uriSafeQueryText);
  var lines = response.getContentText().split("\n");
  var results = [];
  for (line in lines) {
    var curLine = lines[line];
    var match = result_re.exec(curLine);
    if (match != null) {
      results.push(match[1]);
      if (results.length >= maxResults) break;
    }
  }
  return results;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant