Skip to content

Instantly share code, notes, and snippets.

View Gk0Wk's full-sized avatar
💻
Focusing

Ke Wang Gk0Wk

💻
Focusing
View GitHub Profile
@Gk0Wk
Gk0Wk / clean_dsstore.sh
Created July 23, 2021 15:37
一键清理目录下所有.DS_Store
find . -name '.DS_Store' -type f -exec rm -v {} \;
@Gk0Wk
Gk0Wk / find_by_baidu.py
Created July 23, 2021 09:32
百度搜索获取第一页的结果与链接
import requests
from bs4 import BeautifulSoup
def find_page(key_word, page=1):
ret = requests.get(url='https://www.baidu.com/s', params={'wd': key_word, 'pn': page}, headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36'})
soup = BeautifulSoup(ret.content.decode('utf-8'), 'lxml')
return {ele.a.get_text().strip(): ele.a['href'] for ele in soup.select('#content_left>div')}
print(find_page('GitHub'))
@Gk0Wk
Gk0Wk / query_minecraft_server.py
Created July 23, 2021 09:30
查询Minecraft服务器状态
import requests
def query(url:str):
result = requests.get(f'https://api.mcsrvstat.us/2/{url}').json()
import json
if result['debug']['ping'] == False:
return None
else:
return {
'online_players': [player for player in result['players']['uuid'].keys()],
@Gk0Wk
Gk0Wk / github_host.py
Last active July 23, 2021 09:30
(墙内用)获取GitHub的最快HostIP
# 使用说明
# 请先安装`BeautifulSoup`和`requests`,并运行py脚本,将得到的输出保存至hosts文件。
import requests
from bs4 import BeautifulSoup
github_domain_list = [
'github.com',
'github.io',
'githubstatus.com',