Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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})
- {
- "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"
- }
- ]
- }
- {
- "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"
- },
Add Comment
Please, Sign In to add comment