#coding=gbk
from Tkinter import *
import pycurl
import sys, re, md5, os, time, commands
import pycurl
import cStringIO as _StringIO
import sys
import shutil, urllib, urllib2
import socket,sqlite3 as sqlite
import datetime, time
from time import sleep
site='12530'
# MIME type
accept_type = "*/*"
# http transfer limits
connection_timeout = 500
timeout = 1000
low_speed = 200
low_speed_time = 120
max_size = 20485760 # 10MB
root=Tk()
cwd=StringVar(root)
mobile=StringVar(root)
#three=StringVar(root)
text=Entry(root,width=50,textvariable=cwd)
l1=Label(root,text=u"请输入手机号码")
#textmobile=Entry(root,width=50,textvariable=mobile)
textmobile=Text(root,width=50,height=15)
l2=Label(root,text=u"请输入三位数字")
three=Text(root,width=50,height=5)
#text.pack()
l1.pack()
textmobile.pack()
l2.pack()
three.pack()
bfm=Frame(root)
t=Text(root,height=10,background='black',foreground='green')
def dols():
m=textmobile.get('0.0',END)
m=m.strip()
ss=m.split('\n')
ths=three.get('0.0',END)
ths=ths.strip('\n')
sth=ths.split('\n')
count=0
for th in sth:
for s in ss:
if len(s.strip()) == 0 : continue
t.insert('0.0', u"使用号码%s和%s抓取\n" % (s.strip(),th))
print url
v,c,type=get(url,count)
t.update()
sleep(1)
count=count+1
t.insert('0.0',u"抓取已完成,请换批号码再提交\n")
ok=Button(bfm,text=u'提交',activeforeground='white',
activebackground='green',command=dols)
ok.pack()
bfm.pack()
t.pack()
def get_curl(user_agent="MSIE"):
"initialize curl handle"
curl_handle = pycurl.Curl()
curl_handle.setopt(pycurl.FOLLOWLOCATION, 1)
curl_handle.setopt(pycurl.MAXREDIRS, 5)
curl_handle.setopt(pycurl.CONNECTTIMEOUT, connection_timeout)
curl_handle.setopt(pycurl.TIMEOUT, timeout)
curl_handle.setopt(pycurl.NOSIGNAL, 1)
curl_handle.setopt(pycurl.LOW_SPEED_LIMIT, 100)
curl_handle.setopt(pycurl.LOW_SPEED_TIME, low_speed_time)
curl_handle.setopt(pycurl.HTTPHEADER, ["User-Agent: %s" % user_agent, accept_type])
curl_handle.setopt(pycurl.MAXFILESIZE, max_size)
#curl_handle.setopt(pycurl.PROXY, "10.0.0.172")
#curl_handle.setopt(pycurl.PROXYPORT,80)
#curl_handle.setopt(PROXYUSERPWD,"dummyuser:dummypasswd")
return curl_handle
def curl_fetch(curl_handle, url,count):
"retrieve url, return the content, http code, time, effective url"
fp = _StringIO.StringIO()
curl_handle.setopt(pycurl.URL, url)
curl_handle.setopt(pycurl.WRITEFUNCTION, fp.write)
# perform the transfer
try:
curl_handle.perform()
except pycurl.error, e:
print e
return (-1, "", 0)
content_type = curl_handle.getinfo(pycurl.CONTENT_TYPE)
#print curl_handle.getinfo(pycurl.HTTP_CODE)
#t.insert('0.0', u"第 %d 次:Download speed: %.2f bytes/second\n" % (count,curl_handle.getinfo(curl_handle.SPEED_DOWNLOAD)) )
t.insert('0.0',content_type)
t.insert('0.0',u"大小是%s字节\n" %(len(fp.getvalue())) )
t.update()
print content_type
return (0,fp.getvalue(), content_type)
def get(url,count):
handle=get_curl()
v,c,t=curl_fetch(handle,url,count)
handle.close()
return(v,c,t)
root.mainloop()
分享到:
相关推荐
这是Python代码,关于Tkinter图形界面的一些简单的例子,还包括猜数字游戏和模拟计算器界面的简单实现。
适合新手,图书馆管理系统Python+MySQL+tkinter图形化界面+数据库+源码(注释详细) 适合新手,图书馆管理系统Python+MySQL+tkinter图形化界面+数据库+源码(注释详细) 适合新手,图书馆管理系统Python+MySQL+...
【资源说明】 1、该资源包括项目的全部源码,下载可以直接使用! 2、本项目适合作为计算机、数学、...基于python的tkinter图形界面 + 百度人工智能语音识别API + 图灵机器人接口实现的智能聊天机器人系统源码+说明.zip
Tkinter界面设计的图形化设计软件,按钮,下拉菜单,复选框,单选框等实用工具一应俱全!
tkinter全彩版,内容简易详实,全彩印刷看得轻松舒适,一看就懂,一看就可以上手开发python图形界面程序,开发效率高,速度快
不过说实在,使用Python开发GUI界面还是麻烦了一些了,自带的标准库Tkinter使用起来非常简单,不过对于习惯了VB拖放控件完成界面设计的偶来说,还是不够人性化。TK也有一个工具叫GUI Builder,不过它使用Layout布局...
图书馆管理系统Python+MySQL+tkinter图形化界面+数据库+源码(注释详细)适合新手,图书馆管理系统Python+MySQL+tkinter图形化界面+数据库+源码(注释详细)
不过说实在,使用Python开发GUI界面还是麻烦了一些了,自带的标准库Tkinter使用起来非常简单,不过对于习惯了VB拖放控件完成界面设计的同学来说,还是不够人性化。TK也有一个工具叫GUI Builder,不过它使用Layout...
主要为大家详细介绍了python tkinter图形界面代码统计工具,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
基于python的系统开发项目 课程设计 毕业设计 供参考 源代码+说明 基于python的系统开发项目 课程设计 毕业设计 供参考 源代码+说明 基于python的系统开发项目 课程设计 毕业设计 供参考 源代码+说明 基于python的...
利用 tkinter 制作的一个抽奖界面,抽奖转盘自动旋转时自动获取指针指向的当前ID,并在停止时获取输出抽出的奖项名称
本文为大家分享了python tkinter图形界面代码统计工具,供大家参考,具体内容如下 #encoding=utf-8 import os,sys,time from collections import defaultdict from tkinter import * import tkinter.messagebox ...
Tkinter基本控件实现TKinter控件属性优化Tkinter实现视频播放Threading模块实现多线程编程1.0导入包、创建界面类1.1设置窗口标题、界面最大化具体的函数如下所示,先获得当前屏幕的大小,然后设置窗口大小。...
Python基于深度学习和opencv的车牌识别系统源码,并基于tkinter实现图形界面 本次再开发利用tkinter重写编写界面 同时利用对图片每一帧图像加入视频分析模块 图片分析模块可以依据界面按钮提示进行相应功能 视频分析...
基于python图形化界面的学生成绩管理系统.pdf
本案例中计算器的图形用户界面设计将使用 Python内置的 tkinter模块来完成,包括设置窗口的大小和标题、计算器按钮和文本框的大小和位置等。 2.图形用户界面设计只实现了计算器的外观,而界面中各个组件的功能还需要...
项目已获导师指导并通过高分期末大作业项目,可作为课程设计和期末大作业,下载即用无需修改,项目完整确保可以运行。 该系统功能完善、界面...图书馆管理系统Python+MySQL+tkinter图形化界面+数据库+源码(注释详细)
Python之tkinter中文教程,图形界面, Python进阶,Python爬虫基础