Home  >  Article  >  Backend Development  >  How to extract numbers from a web page?

How to extract numbers from a web page?

WBOY
WBOYOriginal
2016-06-27 13:18:111848browse

The following string is part of the web page, 73765ba67e0bf744033b5f4661922847Season number:37bfb51c7a92c9eb3c342e3f21ec17bf More comments (109 in total)5db79b134e9f6b82c0b36e0489ee08ed
       dfs38b7b115160dbbac0c326aa05f7ff72c
Total
e6759ad96e5a04a441b14b465ae277d610954bdf357c58b8a65c66d7c19c8e4d114
Article
5db79b134e9f6b82c0b36e0489ee08edcde686c4dd5bef3d9d501ded9ae26b59 All 109 items5db79b134e9f6b82c0b36e0489ee08ed, how to use regular expressions to extract the three numbers 109, $p_search='/6e27af6592837e834855ba8d07c0ac72(.*)(S*) |(d).*5db79b134e9f6b82c0b36e0489ee08ed/';What’s wrong with this?


Reply to discussion (solution)

$p_search='/e6759ad96e5a04a441b14b465ae277d6(d )d6d448110e0324953b5d7bc1e2b276ce/';
This is enough

(d )

$p_search='/e6759ad96e5a04a441b14b465ae277d6(d ) 54bdf357c58b8a65c66d7c19c8e4d114/';
Isn’t this enough?
You need to extract all 3 109s

$s='<span class="pl">季数:<a href="http://movie.douban.com/subject/3401355/reviews">更多评论(共109条)</a>        dfs<a href="http://movie.douban.com/subject/6973376/reviews">共<span property="v:count">109</span>条</a><a href="http://movie.douban.com/subject/6537486/reviews">全部 109 条</a>';$p_search='#(\d+)(</span>)?\s*条#s';preg_match_all($p_search,$s,$m);print_r($m[1]);

Array
(
[0] = > 109
[1] => 109
[2] => 109
)

PHP code?123456789$s='

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:@someone in the pageNext article:@someone in the page