易截截图软件、单文件、免安装、纯绿色、仅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()


相关文档:

【Python】用Python实现一个俄罗斯方块游戏

俄罗斯方块游戏,使用Python实现,总共有350+行代码,实现了俄罗斯方块游戏的基本功能,同时会记录所花费时间,消去的总行数,所得的总分,还包括一个排行榜,可以查看最高记录。
排行榜中包含一系列的统计功能,如单位时间消去的行数,单位时间得分等。
附源码:
from Tkinter import *
from tkMessageBox import *
i ......

选择阅读Python源码来进一步提高算法

最近在研读Python源码剖析一书,此书相当不错,如果自己冲动的去分析Python源码可能会到处碰“鼻”,看到此书时是09年,那时为了研究内存机制才发现有这么一本书,但是工作太忙,根本没时间去分析源码,到了2010年,这是非常有深重意义的一年,所以这一年一定要比之前做的还要付出更多,要想成为技术顶尖就必须研 ......

python中os.path.dirname(__file__)的使用

     (1).当"print os.path.dirname(__file__)"所在脚本是以完整路径被运行的, 那么将输出该脚本所在的完整路径,比如:
             python d:\pythonSrc\test\test.py
         &nb ......

python语法介绍

1.1. 语法
1.1.1. if
>>> x=int(raw_input("please enter an integer:"))
please enter an integer:-8
>>> if x<0:
...  print 'negative'
... elif x==0:
...  print 'zero'
... else:
...  print 'positive'
...
negative
这里有几个知识点需要提醒:
1。和 ......

python_复杂数据类型

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