Regular expressions
Http://bbs.10jqka.com.cn/codelist.html
Get some of the above links
There are three kinds of Shenzhen, Shanghai stock and fund
What I need to get is the stock name and stock code
For example:
Pudong Hair Bank 600000
Baiyun Airport 600004
Get results
Pudong Hair Bank 600000
Baiyun Airport 600004
Can be directly obtained into
$a =array ("600000" and "pu FA Bank")
It's better to have an array like this.
First of all, thank you, big God.
Reply to discussion (solution)
Preg_match_all ('/
]+> (. +) <\/a><\/li>/isu ', $s, $m);p rint_r ($m [1]);
$str =<<
<>
Pudong Hair Bank 600000
Baiyun Airport 600004STR; Preg_match_all ("/(\s+) \s+ (\d+)/", Preg_replace ("/<\/?[ ^>]+?>/",", $str), $out, preg_set_order); foreach ($out as $a) list ($s, $o [$i], $i) = $a;p rint_r ($o);
]+> ([^\d]+) (\d{6}) <\/a><\/li>/isu ', $str, $match); $a = Array_combine (Array_values ($match [2]), Array_ VALUES ($match [1]);p rint_r ($a);
]+> ([^\d]+) (\d{6}) <\/a><\/li>/isu ', $str, $match); $a = Array_combine (Array_values ($match [2]), Array_ VALUES ($match [1]);p rint_r ($a);
Thanks, you can use this.
Can you tell me how to turn the generated array from GBK to UTF8?
I tried a few of them and failed.
$url = "http://bbs.10jqka.com.cn/codelist.html";
$str = file_get_contents ($url);
$str = Iconv (' GBK ', ' utf-8 ', $str);
Preg_match_all ('/
]+> ([^\d]+) (\d{6}) <\/a><\/li>/isu ', $str, $match);
$a = Array_combine (Array_values ($match [2]), Array_values ($match [1]);
Print_r ($a);$url = "http://bbs.10jqka.com.cn/codelist.html";
$str = file_get_contents ($url);
$str = Iconv (' GBK ', ' utf-8 ', $str);
Preg_match_all ('/
]+> ([^\d]+) (\d{6}) <\/a><\/li>/isu ', $str, $match);
$a = Array_combine (Array_values ($match [2]), Array_values ($match [1]);
Print_r ($a);
Thanks, you can.$url = "http://bbs.10jqka.com.cn/codelist.html";
$str = file_get_contents ($url);
$str = Iconv (' GBK ', ' utf-8 ', $str);
Preg_match_all ('/
]+> ([^\d]+) (\d{6}) <\/a><\/li>/isu ', $str, $match);
$a = Array_combine (Array_values ($match [2]), Array_values ($match [1]);
Print_r ($a);
Ask next, how to put a $ A array inside the subscript prefix to save the 0,3,6, the rest of the to clear out
Is there any easy way?That is, as long as the Shenzhen and SSE data, the Fund's not
Preg_match_all ('/
]+> ([^\d]+) (\d{6}) <\/a><\/li>/isu ', $str, $match);
Switch
Preg_match_all ('/
]+> ([^\d]+) ([036]\d{5}) <\/a><\/li>/isu ', $str, $match);
Preg_match_all ('/
]+> ([^\d]+) (\d{6}) <\/a><\/li>/isu ', $str, $match);
Switch
Preg_match_all ('/
]+> ([^\d]+) ([036]\d{5}) <\/a><\/li>/isu ', $str, $match);
Thank you greatly