仅作练习:1、Python网页抓取
2、Python正则表达式应用
直接上代码:
# coding: utf-8
import os
import re
import sys
import star
import requests
# reload(sys)
# sys.setdefaultencoding("utf-8")
# 基金代码
fundIds = ['000051', '519156', '', '000524', '000960', '163110','000457', '', '519669', '000961','000962','420001', '000697',
'470028', '470009', '001410', '', '110026', '110029', '000603', '', '150182']
def getInfo(url):
html = star.gethtml(url)
text = re.findall('class=\"fundDetail-tit\">(.*?)class=\"dataOfFund-line\"', html, re.S)[0]
text = text.decode('utf-8', 'ignore')