获取内涵段子的python 和 显示图片
来源:互联网 发布:淘宝水兵舞春秋装 编辑:程序博客网 时间:2024/05/17 03:39
# -*- coding: utf-8 -*-
import urllib2,os,cookielib
import sys
type = sys.getfilesystemencoding()
i=0
cookie=cookielib.CookieJar()
opner=urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
while 1==1:
response=opner.open(urllib2.Request('http://neihanshequ.com/'))
html = response.read()
while html.find("data-text=\"")!=-1:
html=html[html.find("data-text=\"")+len("data-text=\""):]
text=html[0:html.find("\"")]
joke=str(i)+'.'+text+'\n'
i+=1
print joke.decode('utf-8').encode(type)
os.system("pause")
html=''
i=0
import wx
class Frame(wx.Frame):
max_width = 400
max_height = 600
def __init__(self,app):
wx.Frame.__init__(self,None,-1,"ShowPic",size=(400,600))
self.bmoved=False
self.app=app
self.bmp = wx.StaticBitmap(self, 0, wx.NullBitmap, (0,0), (400,400))
self.Hide()
def ShowImage(self,path):
image=wx.Image(path,wx.BITMAP_TYPE_ANY)
bmp=image.ConvertToBitmap()
size=self.GetSize(bmp)
print size
self.SetSize(size)
bmp=image.Scale(size[0], size[1]).ConvertToBitmap()
self.bmp.SetSize(size)
self.bmp.SetBitmap(bmp)
self.Show()
def GetSize(self, bmp):
width = bmp.GetWidth()
height = bmp.GetHeight()
if width>self.max_width:
height = height*self.max_width/width
width = self.max_width
if height>self.max_height:
width = width*self.max_height/height
height = self.max_height
size = width, height
return size
class APP(wx.App):
def __init__(self, redirect=False):
wx.App.__init__(self, redirect)
def OnInit(self):
self.frame=Frame(self)
self.ShowImage()
self.frame.Show()
return True
def ShowImage(self):
self.frame.ShowImage("C:\\Users\\Administrator\\Desktop\\1.jpg")
def Close(self):
self.frame.Close()
def main():
app=APP()
app.MainLoop()
if __name__ == '__main__':
main()
0 0
- 获取内涵段子的python 和 显示图片
- 通过抓包获取内涵段子的接口
- Python爬虫:抓取内涵段子1000张搞笑图片-上篇(小爬虫诞生篇)
- Python爬虫:抓取内涵段子1000张搞笑图片-下篇(小爬虫优化篇)
- 内涵爆笑的超冷段子
- 使用python 编写 抓取内涵段子动态图的简单爬虫
- 内涵段子01
- 内涵段子02
- 内涵段子03
- 内涵段子04
- 内涵段子05
- 内涵段子06
- 爬虫 内涵段子
- 程序员才能看得懂的内涵段子
- 网络图片的获取和显示
- Python爬虫爬取内涵吧段子案例系列之八
- python抓取糗事百科段子 图片
- Python抓取段子的爬虫
- MySQL max_allowed_packet 错误
- PLSQL语法&&游标&&存储过程/存储函数&&异常&&触发器
- 程序员转行很难
- Sublime text3 配置 LiveReload
- Linux管道命令学习
- 获取内涵段子的python 和 显示图片
- 当计算机名称修改时,如何解决oracle11g监听问题
- java中的数据存储结构
- 论文学习
- 第一篇博客
- pk10经典挂机模式
- Tornado 与 前端 交互
- Session的实现例子
- 一种图像的曝光增强算法 MATLAB 实现