Guest User

Untitled

a guest
Feb 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. from collections import OrderedDict
  2. import requests
  3. from lxml import html
  4.  
  5.  
  6. @app.route('/saptop', methods=['GET'])
  7. def saptop():
  8.  
  9. page_indo = requests.get('http://www.waterfrontsekuritas.com/marketview')
  10. indo = html.fromstring(page_indo.content)
  11. indo = indo.xpath('//table[@id="top-gainer"]//td/text()')
  12.  
  13. col = ['Stockcode','Lastprice','Prevprice','pc','Change','Tfreq','Vol','Value']
  14.  
  15. c1 = [OrderedDict(zip(col,indo))]
  16. return jsonify({'Stock': c1})
  17.  
  18. {
  19. "Stock": [
  20. {
  21. "Stockcode": "BOSS",
  22. "Lastprice": "1,400",
  23. "Prevprice": "1,120",
  24. "pc": "25.00",
  25. "Change": "280",
  26. "Tfreq": "3,640",
  27. "Vol": "23,087,100",
  28. "Value": "29,132,765,000"
  29. }
  30. ]
  31. }
  32.  
  33. {
  34. "Stock": [
  35. {
  36. "Stockcode": "B",
  37. "Lastprice": "O",
  38. "Prevprice": "S",
  39. "pc": "S"
  40. },
  41. {
  42. "Stockcode": "1",
  43. "Lastprice": ",",
  44. "Prevprice": "4",
  45. "pc": "0",
  46. "Change": "0"
  47. },
  48. {
  49. "Stockcode": "1",
  50. "Lastprice": ",",
  51. "Prevprice": "1",
  52. "pc": "2",
  53. "Change": "0"
  54. },
  55. {
  56. "Stockcode": "2",
  57. "Lastprice": "5",
  58. "Prevprice": ".",
  59. "pc": "0",
  60. "Change": "0"
  61. },
Add Comment
Please, Sign In to add comment