yunfile文件下载脚本
脚本的诞生源自这里python 爬虫求助
脚本的诞生源自这里python 爬虫求助
(图片来自WIKI)
超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议。我们打开浏览器输入网址www.google.com
,不对!刚才那个是一个不存在的网址,我们还是用www.phpgao.com
为例吧。我们(客户端)将老高的域名输入浏览器,浏览器就会为我们呈现老高的网页,首先我们能确定作为客户端,在此期间必定与老高的服务器发生了某种关系!但是具体发送了什么呢?作为一名WEB开发人员,这是我们必须知道的。
老早写的,都忘了当初想干啥了。。。。
半成品,留个坑,待填。
#!/usr/bin/env python
# encoding: utf-8
import cookielib
import requests
def http_send(url, post_data='', **kwargs):
cookie_handler = cookielib.MozillaCookieJar('cookie.txt')
try:
cookie_handler.load(ignore_discard=1)
except cookielib.LoadError, e:
print e + "new cookie file"
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36'}
if post_data:
req = requests.post(url, data=post_data, cookies=cookie_handler)
else:
req = requests.get(url)
print req.headers
for c in req.cookies:
cookie_handler.set_cookie(c)
cookie_handler.save(ignore_discard=1)
return req.content
if __name__ == '__main__':
# init cookie
print http_send('http://localhost/clientarea.php', {"A": 1})
#!/usr/bin/env python
# encoding: utf-8
import cookielib
import requests
from bs4 import BeautifulSoup
import logging
import logging.handlers
import os
import re
logging.basicConfig(filename=os.path.join(os.getcwd(), 'log.txt'), level=logging.DEBUG)
s = requests.session()
def main():
do_login()
scan_list()
check()
def do_login():
global headers, username, password
# get token
# token_html = s.get(login_url).content
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 '
'(KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36'}
token_html = open('C:\Users\Administrator\Desktop\index.html').read()
token = find_token(token_html)
post_data = {'token': token, 'username': username, 'password': password}
s.post(affiliates_url, post_data)
print s.content
def find_token(html):
g = re.findall('name="token"\svalue="(\w+)"\s/>', html)
if g:
return g[0]
else:
log("Could not find token value!")
raise Exception('Could not find token value')
def scan_list():
print 111
def check():
print 111
def log(msg):
logging.debug(msg)
if __name__ == '__main__':
# 初始化参数
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36'}
login_url = "https://bandwagonhost.com/clientarea.php"
affiliates_url = "https://bandwagonhost.com/affiliates.php"
username = 1111
password = 2222
main()
原版shadowsocks使用python写的,源码在此
https://github.com/shadowsocks/shadowsocks
下面老高写一个如何安装shadowsocks并且开启chacha20加密的方法
老高的运行环境
centos6 + python2.6
最近写程序用到了这个模块,但是貌似在