Skip to content

Instantly share code, notes, and snippets.

@quininer
Last active August 29, 2015 14:06
Show Gist options
  • Save quininer/f8311dca8b6767a1459e to your computer and use it in GitHub Desktop.
Save quininer/f8311dca8b6767a1459e to your computer and use it in GitHub Desktop.
URP 1day
#!/usr/bin/env python
# encoding: utf-8
from __future__ import unicode_literals, print_function
from os.path import split, splitext
from optparse import OptionParser
from requests import head, post
from google import search
def upload(url, file):
uploadurl = url + 'lwUpLoad_action.jsp'
fileurl = url+'lwUpLoadTemp/'+split(file)[1]
post(uploadurl, files={
'theFile':open(file, 'rb')
}, data={
'xh':splitext(split(file)[1])[0],
'wjlx':'pdf',
})
if head(fileurl).status_code in (200,):
print('! '+fileurl)
def main(opt, file):
if opt.google and (not opt.url):
for url in search(('intitle:"URP 综合教务系统- 登录"' if opt.google == 'default' else opt.google), tld='com.hk', lang='cn'):
if url: upload(url, file)
elif opt.read and (not opt.url):
for url in open(opt.read, 'r'):
if url: upload(url.strip('\r\n'), file)
else:
upload(opt.url, file)
if __name__ == '__main__':
parser = OptionParser(usage='Usage: %prog [option] file')
parser.add_option('-u', '--url', help='指定上传地址')
parser.add_option('-r', '--read', help='从文本文档中读取URL地址')
parser.add_option('-g', '--google', help='从Google搜集上传地址,参数为default使用默认语句收集')
(opt, args) = parser.parse_args()
if not args:
parser.print_help()
exit()
main(opt, args[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment