There are 10 outputs in json but it is only the first output is shown. How to show all 10 outputs?
from collections import OrderedDict
import requests
from lxml import html
@app.route('/saptop', methods=['GET'])
def saptop():
page_indo = requests.get('http://www.waterfrontsekuritas.com/marketview')
indo = html.fromstring(page_indo.content)
indo = indo.xpath('//table[@id="top-gainer"]//td/text()')
col = ['Stockcode','Lastprice','Prevprice','pc','Change','Tfreq','Vol','Value']
c1 = [OrderedDict(zip(col,indo))]
return jsonify({'Stock': c1})
The current output only shown the first one
{
"Stock": [
{
"Stockcode": "BOSS",
"Lastprice": "1,400",
"Prevprice": "1,120",
"pc": "25.00",
"Change": "280",
"Tfreq": "3,640",
"Vol": "23,087,100",
"Value": "29,132,765,000"
}
]
}
when change to c1 = [OrderedDict(zip(col,t)) for t in indo] , the output as below which is wrong also, all the string is seperated by letter and number:
{
"Stock": [
{
"Stockcode": "B",
"Lastprice": "O",
"Prevprice": "S",
"pc": "S"
},
{
"Stockcode": "1",
"Lastprice": ",",
"Prevprice": "4",
"pc": "0",
"Change": "0"
},
{
"Stockcode": "1",
"Lastprice": ",",
"Prevprice": "1",
"pc": "2",
"Change": "0"
},
{
"Stockcode": "2",
"Lastprice": "5",
"Prevprice": ".",
"pc": "0",
"Change": "0"
},
how to shown all 10 results correctly in Flask? It is json format