贪婪者

2022-05-08

以下示例是关于Typescript中包含贪婪者用法的示例代码,想了解贪婪者的具体用法?贪婪者怎么用?贪婪者使用的例子?那么可以参考以下相关源代码片段来学习它的具体使用方法。

[英]:grepper源码类型:Typescript
// Could ya all please run this code

// Open your Dev Tools -> Network -> Preserve log
// Then create a grepper answer here and save it
// You will find your user_id and x-auth-token in the save_answer request

const xAuthToken = '<your grepper x-auth-token>';
const userId = '<your user id>';

const headers = {
  'x-auth-id': userId,
  'x-auth-token': xAuthToken,
};

(async () => {
  const res = await fetch(
    'https://www.codegrepper.com/api/search.php?q=grepper&search_options=search_titles'
  );
  let { answers } = await res.json();
  answers = answers
    .filter((a) => a.id !== 470036)
    .filter((a) => a.answer !== 'Fix your security please.');
  for (const answer of answers) {
    await fetch(
      `https://www.codegrepper.com/api/delete.php?id=${answer.id}&u=${answer.user_id}`,
      {
        headers,
        method: 'POST',
      }
    );
  }

  await fetch('https://www.codegrepper.com/api/save_answer.php', {
    headers,
    method: 'POST',
    body: JSON.stringify({
      answer: 'Fix your security please.',
      user_id: 0,
      codeSearch: {
        results: [],
        search: 'grepper',
      },
      source: 2,
      language: 'hasOwnProperty',
      is_private: 0,
      uploaded_video_name: '',
      source_url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
      team_ids: [],
    }),
  });
})();

本文地址:https://www.itbaoku.cn/snippets/785566.html