惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
V
Vulnerabilities – Threatpost
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
P
Proofpoint News Feed
G
GRAHAM CLULEY
S
Securelist
P
Palo Alto Networks Blog
MongoDB | Blog
MongoDB | Blog
A
Arctic Wolf
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
WordPress大学
WordPress大学
Project Zero
Project Zero
T
Threat Research - Cisco Blogs
L
Lohrmann on Cybersecurity
C
Cyber Attacks, Cyber Crime and Cyber Security
F
Fortinet All Blogs
博客园 - 叶小钗
B
Blog RSS Feed
C
Cisco Blogs
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Apple Machine Learning Research
Apple Machine Learning Research
G
Google Developers Blog
K
Kaspersky official blog
D
Docker
Latest news
Latest news
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
Cyberwarzone
Cyberwarzone
Security Latest
Security Latest
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
J
Java Code Geeks
Simon Willison's Weblog
Simon Willison's Weblog
T
Tenable Blog
Recent Announcements
Recent Announcements
T
Tailwind CSS Blog
H
Help Net Security
L
LINUX DO - 热门话题
T
The Exploit Database - CXSecurity.com
Jina AI
Jina AI
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
NISL@THU
NISL@THU
美团技术团队
腾讯CDC

博客园 - Yunanw

应用SQLServer For XML 生成XML避免在C# 拼字符串 某些版本的IIS可能有SessionID混淆的Bug 小觑数据库(SqlServer)查询语句执行过程 C#中Finally的一个不太常见的用法 通过表达式树实现的ObjectMapper 实际一个多态(或弱类型)ConfigurationElementCollection 通过P/Invoke调用32位C++ DLL时,一定要将平台改为X86 坑爹的面试题 在Windows2008 IIS7上部署.net 1.1 Python几行代码打印出网卡的Mac地址 放大招,解决前同事签出TFS文件的问题 飞猪传书 Linq To xml 查询时需要注意的一点。 - Yunanw 自定义WinForm 下ListBox的行高 使用LogParser分析网站运行情况(比较简单) 重新装载VS的模板 咱也搞一个TransactionScope QQ斗地主记牌器(只支持角色版) - Yunanw - 博客园 实现支持会话的WebClient
用Python 实现刷钻网上抢任务,并实现一个简单的限制使用时间的功能
Yunanw · 2011-07-20 · via 博客园 - Yunanw

# coding=utf-8
'''
Created on 2011-7-1

@author: Yunanw

'''import cookielib, urllib2, urllib
import time
import lxml.html as H 
import lxml.etree
import ConfigParser
from socket import *
import struct#===============================================================================
#
 此处必改
#
===============================================================================
BuildTime = time.strptime('2011-07-08'"%Y-%m-%d")
Payed 
= False#===============================================================================
#
 常量
#
===============================================================================
CurrentTime = time.strptime('1970-07-08'"%Y-%m-%d")
Password 
= ""
XiaoHao 
= ""
OpCode 
= ""
TaskPage 
= "http://www.shuazuanla.com/taobao.asp?flag=0"
TimeServer 
= "time.apple.com"# 初始化UrlLib模块
cookiejar = cookielib.CookieJar()
proxy 
= urllib2.ProxyHandler({'http''127.0.0.1:8888'})
urlOpener 
= urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
urllib2.install_opener(urlOpener)
def Log(msg):
    
print msg
        
def Post(url, Data):
    request 
= urllib2.Request(url, urllib.urlencode(Data))
    page 
= urlOpener.open(request)
    
return page.read()
    
def Get(url):
    request 
= urllib2.Request(url)
    page 
= urlOpener.open(request)
    
return page.read()def InitConfig():
    config 
= ConfigParser.ConfigParser()
    config.read(
"config.ini"
    
##
    global Password 
    Password 
= config.get("userdata""password"
    
global XiaoHao
    XiaoHao 
= config.get("userdata""xiaohao")
    
global OpCode
    OpCode 
= config.get("userdata""opcode")
    
global TaskPage
    TaskPage 
= config.get("userdata""taskpage")
    
def Login():
    
##登陆URL
    loginUrl = "http://www.shuazuanla.com/user_log.asp"
    usrAndPwd 
= {"UserName":"你的用户名""PassWord":Password}
    
    ret 
= Post(loginUrl, usrAndPwd)
    ret 
= ret.decode('gbk').encode('utf-8')
    
if ret.find('用户名或密码错误'> -1:
        
print U'用户名或密码错误'
        
return False
    
else:
        
return True
        
    
def OpenTaskListPage():
    
return Get(TaskPage)
    
#return Get("http://www.shuazuanla.com/taobao.asp")
   
def AnlyseTaskListPage(taskListPage):
    
#开始分析
    doc = H.document_fromstring(taskListPage)
    trTaskList 
= doc.xpath("//table[@style='background:url(images/fenlei_right.jpg) no-repeat;']//table[last()]/tr[position()>1]")
    
    taskList 
= []
    
    
for trTask in trTaskList:
        tdTaskState 
= trTask.findtext('./td[last()]/a')
        
if tdTaskState == U'等待接手':
            taskList.append(trTask.findtext(
'./td[1]/a'))
            
    
return taskListdef ProcessTask(taskID):
    
print U"找到任务:" + taskID 
    
#ret = submitTask(taskID)
    #print ret.split('<script>')[2]

        
def ProcessTaskAsync(taskID):  
    
return ProcessTask(taskID)  def submitTask(taskID):
    url 
= 'http://www.shuazuanla.com/showinfo.asp?action=sbuto&din=' + taskID
    postData 
= 'xiaohao=&xiaohao=&txiaohao_u842=' + XiaoHao + '&select=&opPassWord=' + OpCode + '&Submit=%C1%A2%BC%B4%BD%D3%CA%D6%C8%CE%CE%F1'
    request 
= urllib2.Request(url, postData)
    
#网站会校验Refrer
    request.add_unredirected_header("Referer"'http://www.shuazuanla.com/showinfo.asp?action=jie&din=' + taskID)
    page 
= urlOpener.open(request)
    
return page.read()def GetNetTime():
    
    
if Payed:
        
return None
    
    time_server 
= (TimeServer, 123)
    TIME1970 
= 2208988800L
    
    client 
= socket(AF_INET, SOCK_DGRAM)
    
    data 
= '\x1b' + 47 * '\0'
    client.sendto(data, time_server)
    
    data, address 
= client.recvfrom(1024)
    
if data:
        t 
= struct.unpack('!12I', data)[10]
        
if t == 0:
            
raise U'取得时间出错'
        
        
global CurrentTime
        CurrentTime 
= time.localtime(t - TIME1970)else:
        
raise U'与时间服务器通信失败'
    
def TimeJudge():
    
if Payed:
        
return True
    seconds 
= time.mktime(BuildTime) - time.mktime(CurrentTime)
    
print seconds
    
if seconds < 0:
        
raise U"试用已到期,请付款"###################################################
#
 自动刷钻程序
#
#
##################################################  

GetNetTime()

#读配置
InitConfig()
#登陆
ret = Login()while(ret): 
    taskListPage 
= OpenTaskListPage()
    TaskList 
= AnlyseTaskListPage(taskListPage)
    
if len(TaskList) == 0:
        
print U'未找到合适任务'
    
    
for taskid in TaskList:
        ProcessTaskAsync(taskid)
    
    TimeJudge()   
    time.sleep(
2)