二进制文件下载地址:
SinaGetBook
效果如图:
代码:
#!/usr/bin/env python
#coding=utf-8
#!/usr/bin/env python
#coding=utf-8
import traceback
import sys
import wx
import re
import urllib
import wx.richtext as rt
import wx.lib.buttonpanel as bp
import Casing
import Debug
def trace_back():
try:
return traceback.print_exc()
except:
return ''
class Window(wx.Frame):
def __init__(self):
sys.setdefaultencoding("utf-8")
wx.Frame.__init__(self,None,-1,u'新浪网图书频道抓取工具',pos=wx.Point(0, 0),size=(800,620))
l1 = wx.StaticText(self, -1, u"目录URL:")
self.t1 = wx.TextCtrl(self, -1, "http://vip.book.sina.com.cn/book/?book=27633", size=(500, -1))
l2 = wx.StaticText(self, -1, u"内容URL前缀:")
self.t2 = wx.TextCtrl(self, -1, "http://vip.book.sina.com.cn/book/", size=(500, -1))
l3 = wx.StaticText(self, -1, u"替换的内容:")
self.t3 = wx.TextCtrl(self, -1,
u"阅读‘刘猛’的其他作品: \n"
u"http://vip.book.sina.com.cn/book/?book=39011《狼牙》作者新作:冰是睡着的水\n"
u"http://vip.book.sina.com.cn/book/?book=41217刘猛展示狙击手神秘生活:刺客\n"
u"http://vip.book.sina.com.cn/book/?book=38884中国特种部队生存实录:狼牙\n"
u"http://vip.book.sina.com.cn/book/?book=43226刘猛最新力作:如临大敌",
size=(500, 100), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
self.t3.SetInsertionPoint(0)
l4 = wx.StaticText(self, -1, u"内容")
#self.t4 = wx.TextCtrl(self, -1,"",
# size=(600, 400), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
self.t4 = rt.RichTextCtrl(self,-1,"",size=(600, 400), style=wx.VSCROLL|wx.HSCROLL|wx.NO_BORDER);
#self.t4.SetInsertionPoint(0)
self.b = wx.Button(self, -1, u"开始抓取")
self.Bind(wx.E
说实话,Python真的不太适合做这种二进制的东西,天生没有指针,导致在C/C++很容易的东西在Python下就很麻烦。不过好像3.1有了原生的bytes类型,不知道能不能改变现状。
import sys
import time
import socket
import struct
import random
def SendPacketData (Buffer = None , DestIP = "127.0.0.1" , DestPort = 0 ......
——由于最近在做有关网页搜索的项目,涉及到一些编码方面的知识,小弟在网上偶然地发现了这么一篇文章,很易懂,不晦涩,为了方便自己也同时能方便大家,就转了过来,以作参考……
文章出处:http://blog.csdn.net/tingsking18/arc ......