![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 23 Pomógł: 3 Dołączył: 8.07.2008 Ostrzeżenie: (0%) ![]() ![]() |
Witam,
mam taki problem. Troche juz na ten temat czytalem choc wyraznie jeszcze za malo i chcialem poeksperymentowac na wlasna reke. Utworzylem na serwerze plik index.php CODE function grab($url) { $user_agent = "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $ch = curl_init(); $headadd=array("Accept: image/gif","Accept-Language: pl"); curl_setopt($ch, CURLOPT_URL, $url); if ($ip!=""){ curl_setopt($ch, CURLOPT_INTERFACE); } curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_HTTPHEADER, $headadd); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 3); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $result = curl_exec($ch); $info = curl_getinfo($ch); $code = $info['http_code']; return $result; } $result = grab('http://encyklopedia.interia.pl'); preg_match_all("/onMouseOut=\"window.status='\'; return true;\" class=\"ht\">([A-z0-9 \-]+)<\/a>/",$result,$domena); print_r($result); ?> oraz .htaccess CODE Options +FollowSymLinks RewriteEngine On RewriteRule ^index.html$ index.php [L] RewriteRule ^haslo-([^-]+)-([^-]+).html$ haslo?hid=$1&kid=$2 [L] RewriteRule ^(.*).html$ litery?l=$1 [L] RewriteRule ^(.*).html$ katalog?kid=$1 [L] RewriteRule ^pk([^-]+)ih([^-]+)kid([^-]+).html$ katalog?kid=$3&pk=$1&ih=$2 [L] zas wyniki nie sa zachwycajace dla mnie. chodzi mi o to ze chcialbym wyciagnac tylko ciag takich znakow: A B C D E F G H I J K L Ł M N O P R S T U W Z z dzialajacymi linkami. czy uzaleznione to jest od ciagu znakow w preg_match_all ? Ten post edytował zukowskp 8.07.2008, 13:25:32 |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 23 Pomógł: 3 Dołączył: 8.07.2008 Ostrzeżenie: (0%) ![]() ![]() |
@webdicepl
zastosowalem sie do Twoich wskazowek, poprawilem preg_match_all oraz dopisalem reszte kodu i wyglada to mniej wiecej tak: CODE function grab($url,$ip) { $user_agent = "User-Agent: Mozilla/5.0 (compatible; MSIE 6.0; Windows NT 5.1)"; $ch = curl_init(); $headadd=array("Accept: image/x-xbitmap, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*","Accept-Language: pl"); curl_setopt($ch, CURLOPT_URL, $url); if ($ip!=""){ curl_setopt($ch, CURLOPT_INTERFACE, $ip); } curl_setopt($ch, CURLOPT_URL, "http://encyklopedia.interia.pl"); curl_setopt($ch, CURLOPT_REFERER, $referer); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_HTTPHEADER, $headadd); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_MAXREDIRS, 3); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $result = curl_exec($ch); $info = curl_getinfo($ch); $code = $info['http_code']; return $result; } $result = grab('http://encyklopedia.interia.pl',''); preg_match_all ('<a href="/litery?l=([A-Z])" class="km"><b>([A-Z])</b></a>', $result, $domena); //print_r($domena); //print_r($array); <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Encyklopedia</title> <META http-equiv="Content-Language" content="pl"> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <!-- Begin Wrapper --> <div id="wrapper"> <!-- Begin Header --> <div id="header"> <h1>Spis tematyczny: </h1><br /><br /><br /> <h2>Wybierz litere: <a href="/litery-A.html" class="km"><b>A</b> </h2> <!-- End Header --> <!-- Begin Strap --> <div id="strap"> </div> <!-- End Strap --> <!-- Begin Navigation --> <div id="navigation"> <ul id="menu"> <li><a href="index.html">Strona główna:</a></li> </ul> </div> <!-- End Navigation --> <!-- Begin Content--> <div id="content"> </div> <!-- End Content --> <!-- Start Footer --> <div id="footer"> <p></p> </div> <!-- End Footer --> </div> <!-- End Wrapper --> </body> </html> .htaccess CODE Options +FollowSymLinks RewriteEngine On RewriteRule ^index.html$ index.php [QSA,L] RewriteRule ^litery-([^-]+).html$ litery?l=$1 [QSA,L] RewriteRule ^haslo-([^-]+)-([^-]+).html$ haslo?hid=$1&kid=$2 [QSA,L] RewriteRule ^katalog([^-]+).html$ katalog?kid=$1 [QSA,L] RewriteRule ^pk([^-]+)ih([^-]+)kid([^-]+).html$ katalog?kid=$3&pk=$1&ih=$2 [QSA,L] narazie chcialem przypisac tylko 1 link dlatego jest tylko literka A, ale wciaz nie dzialaja linki, czy musze cos zdefiniowac dodatkowo? wynik: hxxp://zukowski.info/test co do pliku index.html to dziala (mam na mysli mod_rewrite) |
|
|
![]() ![]() |
![]() |
Aktualny czas: 9.10.2025 - 19:50 |