一段可以无限follow他人的代码

本文介绍了一种使用Node.js库Puppeteer自动化访问GitHub并进行一系列操作的方法,包括登录、浏览关注列表等,通过调整浏览器窗口大小及适当延时来避免被GitHub识别为自动化行为。

const puppeteer = require('puppeteer');
const dely = ms => new Promise(res=> setTimeout(res,ms));

(async () => {
  let pageIndex = 324
  const browser = await puppeteer.launch({
    // 想要代码运的好,还得首选金丝雀
    // args: ['--no-sandbox', '--disable-setuid-sandbox'],
    "executablePath": "C:/Users/33318/AppData/Local/Google/Chrome SxS/Application/chrome.exe",
    timeout: 0,
    // headless: false,
    slowMo: 1,
  });
  const page = await browser.newPage();
  await page.setViewport({
    width: 1600,
    height: 0,
  });
  console.log('设置窗口大小成功');
  await page.goto(`https://github.com/KevinHock?page=${pageIndex}&tab=following`);

  console.log(`去到:https://github.com/KevinHock?page=${pageIndex}&tab=following`);

  const btns = await page.$('.text-bold.text-white.no-underline')
  btns.click()

  await page.waitFor('input[name=login]');
  await page.waitFor('input[name=password]');
  const name = await page.$('input[name=login]');
  const password = await page.$('input[name=password]');
  await name.type('你的账号');
  await password.type('你的密码');
  console.log(`成功输入账号密码`);
  await page.keyboard.press('Enter');



  await page.waitFor('.UnderlineNav.user-profile-nav.js-sticky.top-0');

  // debug tools
  // await page.evaluate(() => {
  //   window.addEventListener('mousemove', (e) => {
  //     try {
  //       const div = document.createElement('div');
  //       div.style.width = '5px';
  //       div.style.height = '5px';
  //       div.style.borderRadius = '50%';
  //       div.style.backgroundColor = 'red';
  //       div.style.position = 'absolute';
  //       div.style.left = `${e.x + 5}px`;
  //       div.style.top = `${e.y + 5}px`;
  //       div.style.zIndex = '99999';
  //       document.body.appendChild(div);
  //     } catch (err) {
  //       console.error(err);
  //     }
  //   });
  // });

  // back to gitter
  await page.setViewport({
    width: 1000,
    height: 800,
  });

  console.log(`重新设置窗口大小`);


  for (let i = 0; i < 100000; i++) {

    _btns = await page.$$('.btn.btn-sm.js-toggler-target')
    for (let i = 0; i < _btns.length; i++) {
      if(i>1 && i%2==0){
        console.log(`当前页面第${i}条,当前是第${pageIndex}页`);
        await dely(3000)
        await _btns[i] && _btns[i].click()
      }
    }
    await page.goto(`https://github.com/KevinHock?page=${pageIndex++}&tab=following`);
    console.log(`去到:https://github.com/KevinHock?page=${pageIndex}&tab=following`);
    console.log(`第${pageIndex}页`);
  }
  await dely(3000)

})()
复制代码



也可以挂自己服务器上面,跑一个星期估计~~被封号~~

不过这哥们没事,我觉得我也应该没事,顺带说一句,玩GitHub还得多follower他人,别人才知道你,对不,多看看别人的项目,偶尔也被惊艳到。


顺便安利chrome canary,超棒的浏览器,感觉比chromium要强


以下是一个简单的C++程序,用于计算给定文法的first集和follow集: ```c++ #include <iostream> #include <vector> #include <unordered_set> #include <unordered_map> #include <string> using namespace std; // 定义产生式 struct Production { string lhs; // 左部 vector<string> rhs; // 右部 }; // 计算first集 unordered_map<string, unordered_set<string>> first(const vector<Production>& productions) { unordered_map<string, unordered_set<string>> first_set; for (const auto& production : productions) { const auto& lhs = production.lhs; const auto& rhs = production.rhs; if (rhs.empty()) { first_set[lhs].insert(""); } else if (isupper(rhs.front()[0])) { first_set[lhs].insert(first_set[rhs.front()].begin(), first_set[rhs.front()].end()); } else { first_set[lhs].insert(rhs.front()); } for (size_t i = 1; i < rhs.size(); ++i) { if (isupper(rhs[i - 1][0])) { first_set[lhs].insert(first_set[rhs[i - 1]].begin(), first_set[rhs[i - 1]].end()); } if (!is_nullable(first_set, rhs[i - 1])) { break; } if (isupper(rhs[i][0])) { first_set[lhs].insert(first_set[rhs[i]].begin(), first_set[rhs[i]].end()); } else { first_set[lhs].insert(rhs[i]); } } } return first_set; } // 判断符号串是否可以推出空串 bool is_nullable(const unordered_map<string, unordered_set<string>>& first_set, const string& symbol) { const auto& it = first_set.find(symbol); if (it == first_set.end()) { return false; } const auto& s = it->second; return s.find("") != s.end(); } // 计算follow集 unordered_map<string, unordered_set<string>> follow(const vector<Production>& productions, const unordered_map<string, unordered_set<string>>& first_set) { unordered_map<string, unordered_set<string>> follow_set; follow_set[productions.front().lhs].insert("$"); bool changed = true; while (changed) { changed = false; for (const auto& production : productions) { const auto& lhs = production.lhs; const auto& rhs = production.rhs; for (size_t i = 0; i < rhs.size(); ++i) { if (!isupper(rhs[i][0])) { continue; } const auto& symbol = rhs[i]; if (i < rhs.size() - 1) { const auto& beta = rhs.substr(i + 1); const auto& beta_first = first_of_string(first_set, beta); if (beta_first.find("") != beta_first.end()) { const auto& follow_lhs = follow_set[lhs]; changed |= follow_set[symbol].insert(follow_lhs.begin(), follow_lhs.end()).second; } changed |= follow_set[symbol].insert(beta_first.begin(), beta_first.end()).second; } else { changed |= follow_set[symbol].insert(follow_set[lhs].begin(), follow_set[lhs].end()).second; } } } } return follow_set; } // 计算符号串的first集 unordered_set<string> first_of_string(const unordered_map<string, unordered_set<string>>& first_set, const string& str) { unordered_set<string> result; for (size_t i = 0; i < str.size(); ++i) { if (!isupper(str[i])) { result.insert(str.substr(i, 1)); break; } const auto& symbol = str.substr(i, 1); result.insert(first_set.at(symbol).begin(), first_set.at(symbol).end()); if (!is_nullable(first_set, symbol)) { break; } if (i == str.size() - 1) { result.insert(""); } } return result; } int main() { vector<Production> productions = { {"E", {"T", "E'"}}, {"E'", {"+", "T", "E'"}}, {"E'", {""}}, {"T", {"F", "T'"}}, {"T'", {"*", "F", "T'"}}, {"T'", {""}}, {"F", {"(", "E", ")"}}, {"F", {"id"}}, }; const auto& first_set = first(productions); const auto& follow_set = follow(productions, first_set); // 输出first集 for (const auto& [lhs, set] : first_set) { cout << "first(" << lhs << ") = { "; for (const auto& s : set) { cout << s << " "; } cout << "}" << endl; } // 输出follow集 for (const auto& [lhs, set] : follow_set) { cout << "follow(" << lhs << ") = { "; for (const auto& s : set) { cout << s << " "; } cout << "}" << endl; } return 0; } ``` 以上程序根据给定的文法计算first集和follow集。在程序中,将文法表示为一组产生式,每个产生式包含一个左部和右部。在计算first集和follow集时,使用unordered_map和unordered_set来存储集合。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值