易截截图软件、单文件、免安装、纯绿色、仅160KB

Python简易股票查询(抓取google财经的内容)


看着网上抓取网页数据的文章直瞪眼
后来想到用字符串分割来提取相应部分的内容
程序简单,但数行数和下标费了很长时间
我知道这肯定不是最好的办法- -!!
但我实现了,哈哈
# -*- coding: cp936 -*-
from urllib import *
import re
def stockSearch():
    baseurl="http://www.google.cn/finance?q=SHA%3A"
    stockNo=raw_input("请输入股票代码:")
    fullUrl=baseurl+stockNo
    #print fullUrl 
    stockPage=urlopen(fullUrl)
    pageInfo=stockPage.readlines()
    stockNameLine=pageInfo[4]
    stockNameList=re.split('[ >]',stockNameLine)
    print "您所查询的股票是:"+stockNameList[1]
    stockInfoLine=pageInfo[184]
    stockInfoList=re.split('values',stockInfoLine)
    stockInfoDetail=re.split('"',stockInfoList[1])
    print "现价:"+stockInfoDetail[3]
    print "涨幅: "+stockInfoDetail[5]+"%"
    print "每股收益: "+stockInfoDetail[9]
    print "市值: "+stockInfoDetail[11]
    chengJiaoLiang=re.split('[><]',pageInfo[248])
    print "成交量: "+chengJiaoLiang[2]
while True:
    stockSearch()


相关文档:

我的VIM配置(ubuntu+python)

1,不用修改/etc/vim下的vimrc及gvimrc文件 。。。
      2,在~目录下,新建一个.vimrc的配置文件。内容如下:(高亮,自动对齐,自动缩进,显示行号)
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2006 Nov ......

【Python】用Python来实现凑24的程序

凑24是经典的益智游戏,多玩可以使脑筋灵活一点,但是当遇到无解的时候,就会很伤脑筋,为此,写个程序来代为计算。
运行结果,去除了重复的一些表达式:
entry: 1
entry: 4
entry: 5
entry: 6
(4/(1-(5/6))) = 24
(6/((5/4)-1)) = 24
Press any key to exit...
entry: 3
entry: 3
entry: 8
entry: 8
(8/(3-(8 ......

beginning python summary chapter 3 使用字符串

0、字符串是不可变的。
1、基本字符串操作:索引、切片、复制、成员、长度、最大和最小。
2、字符串格式化:用格式化操作符百分号%实现,eg:>>> format = "Hello, %s. %s enough for ya?"
                    ......

Python重载学习手记

今天学习了一下Python的操作符重载,总结了几点比较神奇的东东:
------------------------------------------------------------------------------------------------------------
关于iter:
Technically, iteration contexts work by calling the iter built-in function to try to
find an _ _iter_ _ method, whi ......

python_复杂数据类型

python_复杂数据类型
python中原生的队列有2种,一种是普通的队列(Queue),一种叫做优先队列(PriorityQueue),即小的先出列。
注意:队列是线程安全的,python 3.0中支持多进程,也有类似的Queue,但不是这个。
1栈、队列、堆
  python中原生的队列有2种,一种是普通的队列(Queue),一种叫做优先队列(PriorityQueu ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号