Sina Stock Data Interface
Take Daqin Railway (stock code: 601006) as an example. If you want to get its latest quotes, just visit Sina’s stock data interface:
http://hq.sinajs.cn/list=sh60...
This url will return a string of text, for example:
var hq_str_sh601006="Daqin Railway, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92,
22114263, 589824680, 4695, 26.91 , 57590, 26.90, 14700, 26.89, 14300,
26.88, 15100, 26.87, 3100, 26.92, 8900, 26.93, 14230, 26.94, 25150, 26.95, 15220, 26.96, 2008-01-11, 15:05:32";
How can I let php get this string?
Sina Stock Data Interface
Take Daqin Railway (stock code: 601006) as an example. If you want to get its latest quotes, just visit Sina’s stock data interface:
http://hq.sinajs.cn/list=sh60...
This url will return a string of text, for example:
var hq_str_sh601006="Daqin Railway, 27.55, 27.25, 26.91, 27.55, 26.20, 26.91, 26.92,
22114263, 589824680, 4695, 26.91 , 57590, 26.90, 14700, 26.89, 14300,
26.88, 15100, 26.87, 3100, 26.92, 8900, 26.93, 14230, 26.94, 25150, 26.95, 15220, 26.96, 2008-01-11, 15:05:32";
How can I let php get this string?
curl
ah. Give it a try for reference
<code>function getCurlData($url) { if (empty ( $url )) { return false; } $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $url ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_HEADER, 0 ); $output = curl_exec ( $ch ); curl_close ( $ch ); return $output; }</code>
It is recommended that you use curl
Direct access via get method, list is the parameter
No need for php, just use <script>
to import it and use the hq_str_sh601006
variable. Do you want to cache it? There is no need at all, Sina has already cached it. This is already very fast