я пытаюсь найти ссылку на странице
Ссылка выглядит так
https://pos.xxxxxxxxxx.de/xxxxxxxxxxxx/app?funnel=login_box&tid=2001004
я скрываю домен:)
Так вот мой код:
preg_match('~(https://pos.xxxxxxxxxx.de/xxxxxxxxxx/app\?funnel=login_box&tid=\d+)~', $text, $ans);
ничего не найдено ...
Я попробую это
preg_match('~(https://pos.xxxxxxxxxx.de/xxxxxxxxxx/app\?funnel=login_box&tid=)~', $text, $ans);
попробуйте найти только фиксированную часть ссылки ...
пока ничего
так что я попробую это
preg_match('~(https://pos.xxxxxxxxxx.de/xxxxxxxxxx/app\?funnel=login_box)~', $text, $ans);
теперь я нахожу несколько ссылок, но почему я не могу найти всю ссылку ???
Возможно, в html-источнике, & расширен до &, попробуйте:
&
&
&(amp;)?
Просто напоминание - . означает каждый символ, поэтому вы должны избегать его, но здесь это не важно.
.
$html = "http://www.scroogle.org http://www.scroogle.org/ http://www.scroogle.org/index.html http://www.scroogle.org/index.html?source=library You can surf the internet anonymously at https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi."; preg_match_all('/\b((?P<protocol>https?|ftp):\/\/(?P<domain>[-A-Z0-9.]+)(?P<file>\/[-A-Z0-9+&@#\/%=~_|!:,.;]*)?(?P<parameters>\?[A-Z0-9+&@#\/%=~_|!:,.;]*)?)/i', $html, $urls, PREG_PATTERN_ORDER); $urls = $urls[1][0];
Будет соответствует :
http://www.scroogle.org
http://www.scroogle.org/
http://www.scroogle.org/index.html
http://www.scroogle.org/index.html?source=library
Вы можете просматривать Интернет анонимно по номеру https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi.
To Результаты цикла Вы можете использовать:
for ($i = 0; $i < count($urls[0]); $i++) { echo $urls[1][$i]."\n"; }
выведет:
http://www.scroogle.org http://www.scroogle.org/ http://www.scroogle.org/index.html http://www.scroogle.org/index.html?source=library https://ssl.scroogle.org/cgi-bin/nbbwssl.cgi
ура, Лоб
preg_match ( "/ (https://[^=]+=[^=]+=[\d]+)/i",$text,$m);
если у вас есть 'или' в конце ссылки, что-то вроде этого href = "https: // ....."
Вы можете использовать это: preg_match ("/ \" (https://[^\"]+)\"/i",$text,$m);