php正则表达式抓取网页部分内容

2024-11-01 18:16:11
推荐回答(4个)
回答1:

$str = '
1
A1
98678
101516
710610

A2
A3
A4



2
B1
24692
33096
231669>

B2
B3
B4


';
preg_match_all("/\w*<\/a>/iUs",$str,$arr);
print_r($arr);
?>

回答2:

$str
=
'
class="rank">1
target="_blank"
href="A1">A1

98678
101516
710610

target="_blank"
href="A2">A2
target="_blank"
href="A3">A3
target="_blank"
href="A4">A4



class="rank">2
target="_blank"
href="B1">B1
24692
33096
231669>

target="_blank"
href="B2">B2
target="_blank"
href="B3">B3
target="_blank"
href="B4">B4


';
preg_match_all("/target=\"\w*\"
href=\"\w*\">\w*<\/a>/iUs",$str,$arr);
print_r($arr);
?>

回答3:
回答4:

abcdefg