def industry(names=False, rigs=True, categories=[0], detail=-1): for cat in categories: if not cat in (0, 6, 7, 8, 18, 22): raise LookupError i = Industry(names=names, rigs=rigs, categories=categories, detail=detail) items = i.fetch() return jsonify(items=items)
def parseIndustry(): url = 'http://www.sse.com.cn/sseportal/webapp/datapresent/SSEQueryFirstSSENewAct' from lxml import etree from lxml.html import parse page = parse(url).getroot() result = etree.tostring(page) #print result #r = page.xpath('//td[@class="table3"]'); r = page.xpath('//tr[@valign="top"]'); #print len(r) from industry import Industry for data in r: dataTree = etree.ElementTree(data); #print etree.tostring(dataTree) #values = dataTree.xpath('//text()') row = dataTree.xpath('//td') length = len(row) #print length if (length ==5): continue rows = [] for column in row: col = etree.ElementTree(column) #print etree.tostring(col) values = col.xpath('//text()') temp = values[0].strip() #print temp rows.append(temp) industry = Industry() name = str(rows[0]) href = dataTree.xpath('//a/@href') print href try: pe = float(rows[4]) avgPrice = str(rows[5]) industry.name = name industry.PE = pe industry.avgPrice = avgPrice except: continue print industry newUrl = 'http://www.sse.com.cn'+str(href[0]) print newUrl newPage = parse(newUrl).getroot() newResult = etree.tostring(newPage) print newResult
def parseIndustry(): url = 'http://www.sse.com.cn/sseportal/webapp/datapresent/SSEQueryFirstSSENewAct' from lxml import etree from lxml.html import parse page = parse(url).getroot() result = etree.tostring(page) #print result #r = page.xpath('//td[@class="table3"]'); r = page.xpath('//tr[@valign="top"]') #print len(r) from industry import Industry for data in r: dataTree = etree.ElementTree(data) #print etree.tostring(dataTree) #values = dataTree.xpath('//text()') row = dataTree.xpath('//td') length = len(row) #print length if (length == 5): continue rows = [] for column in row: col = etree.ElementTree(column) #print etree.tostring(col) values = col.xpath('//text()') temp = values[0].strip() #print temp rows.append(temp) industry = Industry() name = str(rows[0]) href = dataTree.xpath('//a/@href') print href try: pe = float(rows[4]) avgPrice = str(rows[5]) industry.name = name industry.PE = pe industry.avgPrice = avgPrice except: continue print industry newUrl = 'http://www.sse.com.cn' + str(href[0]) print newUrl newPage = parse(newUrl).getroot() newResult = etree.tostring(newPage) print newResult
from flask_wtf import FlaskForm from wtforms import StringField, PasswordField, SelectField, SelectMultipleField, HiddenField from wtforms.validators import DataRequired, Email, Optional, EqualTo from wtforms.fields.html5 import TelField from industry import Industry from waste import Waste from states import State from district import District from place import Place ALL_INDUSTRIES = Industry.get_all_industry() ALL_WASTES = Waste.get_all_waste() ALL_STATES = State.get_all_states() ALL_DISTRICTS = District.get_all_district() ALL_PLACES = Place.get_all_places() class EmailPasswordForm(FlaskForm): email = StringField('Email', validators=[DataRequired(), Email()]) password = PasswordField('Password', validators=[DataRequired()]) class ResetPasswordForm(FlaskForm): email = StringField('Email', validators=[DataRequired(), Email()]) password = PasswordField('Password', validators=[DataRequired(), EqualTo('confirm', message='Passwords must match')]) confirm = PasswordField('Repeat Password') class RegisterForm(FlaskForm): industry = SelectField('Industry', choices=map(lambda x: (str(x.id), x.industry), ALL_INDUSTRIES))