Re: [請益] preg_match_all的問題
※ 引述《AMOUAMOU (AMOU)》之銘言:
: E%B6%E5%A5%BD&fr2=tab-web
: 而我想抓搜尋頁面裡面的各個連結和分頁連結
: 我發現到連結都是由
: <a href="http://tw.wrs.yahoo.com/_ylt=A8tUxyqKvHNHHy4AQQNw1gt./SIG=
: 12f1n7o30/EXP=1198853642/**http%3A//
: tw.news.yahoo.com/article/url/d/a/071128/1/ozs4.html" target=_blank>
: 且當我在抓分頁連結的時候,嘗試了很多種判斷方法,都無法順利抓到,好像在判斷
: _底線的時候出了問題,我就算使用了[_]也沒辦法解決,我在這方面是新手,希望各位
: 大大可以指導我,非常感謝!!
'/<a .*href=(["|\'])([^\\1]*?)\\1/im'
一行太短. 所以加點注解/
.*
=> 防止中間有什麼 class xx oo 的東西.
(["|\']) 最好用[\"|\']
=> 抓出是用 ' or " 作開頭...
[^\\1]*?
=>不是 開頭的 " or ' 所有字符
*? greek match
\\1 結尾的 ' or "
如果 200% 確定 他們不會用 ' 當開頭那就 href="([^"]*)"
搞定收工
--
Exactly. For that one fraction of a second, you were open to options
you had never considered. THAT is the exploration that awaits you:
not mapping stars and studying nebulae,but
charting the unknown possibilities of existence.
Star Trek S7E26 "All Good Thing"
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 60.248.154.212
※ 編輯: alpe 來自: 60.248.154.212 (12/28 10:01)
推
12/28 12:46, , 1F
12/28 12:46, 1F
推
12/28 21:32, , 2F
12/28 21:32, 2F
→
12/28 22:55, , 3F
12/28 22:55, 3F
→
12/31 11:26, , 4F
12/31 11:26, 4F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 4 篇):
PHP 近期熱門文章
PTT數位生活區 即時熱門文章