The Sina stock data interface takes Daqin Railway (stock code: 601006) as an example. to obtain its latest stock information, you only need to access Sina stock data interface: hq. sinajs. cnlistsh60... this url returns a string of text, such as varhq_str_sh601006 & quot; Daqin Railway ,... sina stock data interface
Take the Daqin Railway (stock code: 601006) as an example. to get its latest market, you only need to access Sina's stock data interface:
Http://hq.sinajs.cn/list=sh60...
This url returns 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,589 listen 680, 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, 15:05:32 ";
How can php get this string?
Reply content:
Sina stock data interface
Take the Daqin Railway (stock code: 601006) as an example. to get its latest market, you only need to access Sina's stock data interface:
Http://hq.sinajs.cn/list=sh60...
This url returns 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,589 listen 680, 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, 15:05:32 ";
How can php get this string?
curl
Ah. Try again
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;}
We recommend that you use curl
Direct get access. list is the parameter.
Php is not required.《script》
You can usehq_str_sh601006
Variable. do you want to cache it? It's not necessary at all. Sina has already cached it. it's very fast.