Thu Aug 24 22:43:47 CST 2017

This commit is contained in:
ddv12138 2017-08-24 22:43:47 +08:00
commit 1808581aa2
4 changed files with 139 additions and 16 deletions

View File

@ -1,5 +1,23 @@
# Some useful scripts
# 一些有用的脚本
python3.5-for-spider.sh
===================
##### 一键运行单个的python脚本
- 含有python3.5,requsets, beautifulsoup4
- 运行此脚本时,接收一个参数,参数为要运行的脚本的文件名,例如"./python3.5-for-spider.sh example.py"
- 需要docker环境的支持
***
newlinux.sh
===================
##### 用来在新的linux上安装必要环境
- 含有screenfetch mycli speedometer shadowsocks 以及java8
***
install-docker.sh
===================
##### docker安装脚本
***
l2tp.sh
=======
@ -16,16 +34,16 @@ Usage: l2tp [-l,--list|-a,--add|-d,--del|-m,--mod|-h,--help]
| l2tp -m,--mod | Modify a user password |
| l2tp -h,--help | Print this help information |
```
***
bbr.sh
======
- 一键升级内核以支持谷歌bbr加速技术
- Description: Auto install latest kernel for TCP BBR
- Intro: https://teddysun.com/489.html
***
bench.sh
========
- vps性能及连接速度测试
- Description: Auto test download & I/O speed script
- Intro: https://teddysun.com/444.html
```bash
@ -38,7 +56,7 @@ Usage:
| 3 | wget -qO- 86.re/bench.sh | bash |
| 4 | curl -so- 86.re/bench.sh | bash |
```
***
backup.sh
=========
@ -61,20 +79,20 @@ For i386:
wget -O /usr/bin/gdrive http://dl.lamp.sh/files/gdrive-linux-386
chmod +x /usr/bin/gdrive
```
***
ftp_upload.sh
=============
- You must modify the config before run it
- Upload file(s) to FTP server
- Intro: https://teddysun.com/484.html
***
unixbench.sh
============
- Description: Auto install unixbench and test script
- Intro: https://teddysun.com/245.html
***
pptp.sh(Deprecated)
===================
@ -82,8 +100,3 @@ pptp.sh(Deprecated)
- Intro: https://teddysun.com/134.html
Copyright (C) 2013-2017 Teddysun <i@teddysun.com>
newlinux.sh
===================
##### 用来在新的linux上安装必要环境
-含有screenfetch mycli speedometer shadowsocks 以及java8

109
cet_query.py Normal file
View File

@ -0,0 +1,109 @@
#!/usr/bin/env python3
#coding=utf-8
def text(files):
with open('cet.txt','w+') as f:
f.write(files)
def read_text():
with open('cet.txt','r') as f:
data = f.read()
return data
import requests,os
from time import sleep
from urllib.parse import quote
from bs4 import BeautifulSoup as bs
URL='http://www.chsi.com.cn/cet/'
data = 'query?zkzh={}&xm={}'
H = {'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
'Accept-Encoding':'gzip, deflate',
'Accept-Language':'zh-CN,zh;q=0.8',
'Connection':'keep-alive',
'Host':'www.chsi.com.cn',
'Referer':'http://www.chsi.com.cn/cet/',
'Upgrade-Insecure-Requests':'0',
'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36',
}
def query(id__,name):
s = requests.Session()
req = s.get(URL,headers=H)
if req.ok :
url = URL + data.format(id__,quote(name))
print(url)
req = requests.get(url,headers=H,cookies=req.cookies)
return req.text
else:
print(id__,name,'出错',sep='-->')
return False
def check(html):
soup = bs(html,'html.parser')
if soup.find('div',{"class":"error alignC marginT20"}):
return False
elif soup.find('div',{"class":"error alignC"}):
print('要求验证码')
return False
else:
return True
#html = read_text()
def parse(html):
soup = bs(html,'html.parser')
table = soup.find('table',{"border":"0","align":"center"})
string = ''
for n in table.getText().split():
string += n
return string
def append_file(string):
with open('cet.txt','a+') as f:
f.writelines(string + os.linesep)
number = 420550171103500,420550171103600 ### 420550171103524 贺深
### testing
text = query(420550171103524,'贺深')
if check(text):
print(parse(text))
else:
print('没有')
exit(0)
### testing end
names = ['贺深','张旭','尘飞杨']
'''for xm in names:
for zkzh in [ i for i in range(*number) ]:
sleep(10)
text = query(zkzh,xm)
if check(text):
print('result has been checked')
result = parse(text)
print(result)
append_file(result)
else:
print('result has not been checked')
print(zkzh,xm,sep='-->')'''
'''text = query('420550171103524','贺深')
if check(text):
print('result has been checked')
result = parse(text)
print(result)
append_file(result)
else:
print('result has not been checked')'''

4
install-docker.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
set -e
echo "开始安装docker"
wget -qO- https://get.docker.com/ | sh

View File

@ -1,3 +0,0 @@
#!/bin/bash
set -e
docker run -it --rm --name my-running-script -v `pwd`:/usr/src/myapp -w /usr/src/myapp ddv12138/python:3.5 python $1