Skip to content

Instantly share code, notes, and snippets.

View SuperHuangXu's full-sized avatar
🏳️‍🌈

Bubble SuperHuangXu

🏳️‍🌈
View GitHub Profile
@SuperHuangXu
SuperHuangXu / index.py
Created October 15, 2018 03:50
用Python爬取教务个人信息
import requests
from bs4 import BeautifulSoup
if __name__ == "__main__":
def getData(myInfo):
# 首页
homeUrl = "http://uia.whxy.edu.cn/cas/login?service=http%3A%2F%2Fportal.whxy.edu.cn%2Fc%2Fportal%2Flogin"
# 登录
loginUrl = homeUrl + "%3Fredirect%3D%252Fweb%252Fguest%252Findex%26p_l_id%3D10213"
# 教务登录
@SuperHuangXu
SuperHuangXu / main.ts
Created March 25, 2018 10:51
使用 puppeteer 从教务处爬取个人信息
import * as puppeteer from "puppeteer";
import { Page } from "puppeteer";
/**
* 登录
* @param {string} username
* @param {string} password
* @returns {Promise<{code: number; data: {balance: string}; info: {}}>}
*/
async function login(username: string, password: string) {
@SuperHuangXu
SuperHuangXu / demo1.js
Created January 6, 2018 09:57
使用puppeteer截图
'use strict';
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
// 设置Chromium位置
executablePath: 'D:\\Program Files (x86)\\Yarn\\chrome\\chrome.exe',
env: {
CHROME_PATH: puppeteer.executablePath(),
@SuperHuangXu
SuperHuangXu / client.js
Created January 6, 2018 09:57
nodejs中net模块(TCP)的基本使用方法
const net = require('net');
// 客户端
const client = net.connect({port: 8124}, () => {
//'connect' listener
console.log('connected to server!');
client.write('client send...\n');
});
client.write('world!\r\n');
@SuperHuangXu
SuperHuangXu / demo.ts
Created January 6, 2018 09:55
nodejs输入输出
import * as readline from 'readline';
import * as fs from 'fs';
import * as path from 'path';
function scan(): Promise<void> {
return new Promise((resolve, reject) => {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
@SuperHuangXu
SuperHuangXu / app.js
Created January 6, 2018 09:34
如何使用JWT?
'use strict';
const express = require('express');
const jwt = require('jsonwebtoken');
const app = express();
const PORT = 4000;
// 可以fs.readfile...
const SECRET_KEY = 'secretkey123';
// 配置,expires:过期时间。
const jwtConfig = {expiresIn: '18s'};