Heim > Fragen und Antworten > Hauptteil
<dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbc8ups.html" target="_blank">20170408$http://www.iqiyi.com/v_19rrbc8ups.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbd47ic.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrbd47ic.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrnfp1nk.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrnfp1nk.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbcsn9g.html" target="_blank">20170406$http://www.iqiyi.com/v_19rrbcsn9g.html</a></dd>
Ich möchte den Wert im a-Tag durchlaufen, zum Beispiel:
20170408$http://www.iqiyi.com/v_19rrbc...
20170407$http://www.iqiyi.com/v_19rrbd...
Wie soll ich es schreiben?
世界只因有你2017-05-16 13:18:57
preg_match_all('/(\d{8}\$[^<]+)/', $subject, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[0]); $i++) {
# Matched text = $result[0][$i];
}
怪我咯2017-05-16 13:18:57
用正则弄这个感觉好繁琐,能不能直接查找标签像下面这样:
var a = document.querySelectorAll('a');
a.forEach((item)=>{
console.log(item.innerText);
})
怪我咯2017-05-16 13:18:57
$string = '<dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbc8ups.html" target="_blank">20170408$http://www.iqiyi.com/v_19rrbc8ups.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbd47ic.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrbd47ic.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrnfp1nk.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrnfp1nk.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbcsn9g.html" target="_blank">20170406$http://www.iqiyi.com/v_19rrbcsn9g.html</a></dd>';
$ret = preg_match_all('#(<a.*?>)(.*?)(</a>)#', $string, $matchs);
var_dump($matchs);
过去多啦不再A梦2017-05-16 13:18:57
$pattern = '/<a[^>]*>([^<]*)<\/a>/';
$temp = preg_match_all($pattern, $html, $match);