dongwuxie7976 2014-02-20 07:39
浏览 21
已采纳

如何从网页获取特定数字(例如股票价格)[关闭]

I want to get stock price from this site: http://en.tsetmc.com/. There is a page that tell us all price in this stocks: http://en.tsetmc.com/loader.aspx?ParTree=121C1111

I tried to get this page content by this code:

$address ="http://en.tsetmc.com/loader.aspx?ParTree=121C1111";
    $page = file_get_contents($address);

but page send this error

General Error Detected

Please Try Later

It's the only idea that i have to get data and manipulate it later to get prices.

but I know that there is a better way to get this price.

I want to create an online portfolio manager for school project, and i really need to get stock prices. I know nothing about Javascript or python and use php to handle it, but if they give me a solution I'll be thankful for them and you.

Thank you for helping :)

  • 写回答

3条回答 默认 最新

  • douhui3305 2014-02-20 07:46
    关注

    That websites' data is loaded via ajax request.

    You can access it like this:

    $content = file_get_contents('http://en.tsetmc.com/tse/data/TradeLastDayData3.aspx?CComVal=&CSecVal=&HEven=0&RefID=0');   //returns json values
    
    
    $values = json_decode($content,true);   // put json into asso. array
    
    
    print_r($values);  //acccess your data via array
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教