funcion para buscar arhcivos dentro de sitio web

PHOTO EMBED

Sun Nov 27 2022 20:19:49 GMT+0000 (Coordinated Universal Time)

Saved by @modesto59 #html

/* create a function that searches internal files of a website */
function searchFiles(query) {
  var xhr = new XMLHttpRequest();
  xhr.open('GET', 'https://api.github.com/search/code?q=' + query, true);
  xhr.onreadystatechange = function() {
    if (xhr.readyState == 4) {
      var results = JSON.parse(xhr.responseText);
      var resultsDiv = document.createElement('div');
      resultsDiv.innerHTML = '<h2>Results</h2>';
      for (var i = 0; i < results.items.length; i++) {
        var result = results.items[i];
        var resultDiv = document.createElement('div');
        resultDiv.innerHTML = '<a href="' + result.html_url + '">' + result.html_url + '</a>';
        resultsDiv.appendChild(resultDiv);
      }
      document.body.appendChild(resultsDiv);
    }
  };
  xhr.send();
}
content_copyCOPY