![]() |
![]() |
![]() ![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 243 Pomógł: 1 Dołączył: 1.06.2010 Ostrzeżenie: (0%) ![]() ![]() |
Mam problem z tym jak sprawdzić czy dana strona wczytywana przez curl i czy wczytała się do końca.
Nie znam strony, która ma się wczytać bo będą to różne strony. Nie znam też jej wielkości. Ale chcę sprawdzić czy strona się wczytała do końca. W jednej aplikacji mam problem jak to stwierdzić. Napisałem więc funkcje sprawdzające w oparciu o preq_match_all aby mieć pewność, że strona się wyczytała. Napisałem dwa warunki , które mają potwierdzić czy strona się wczytała. Sprawdzenie pierwsze na to czy na końcu kodu wczytywanej strony jest poszukiwany przez mnie ciąg znaków, który wiem , że tam na pewno wystąpi w tej stronie. Sprawdzenie drugie czy w stronie jest ciąg znaków , który ta strona musi zawierać np nazwa jej domeny. Jeśli te dwa warunki będą spełnione to uznawałem, że strona się wczytała. Niestety przez serwery proxy działa to różnie. Dlatego mam też pytanie jak inaczej to sprawdzać ? Czy Curl daje możliwość sprawdzenia czy operacja wczytywania zakończyła się poprawnie i nie została przerwana ?
Czasami mam taki wynik, że znalazłem wynosi 1 - czyli strona się niby wczytała. Ale pozycja nie jest wyliczana. Jak przejdę na inne proxy to wszystko jest ok. Istna ruletka. Nie wiem dlaczego raz mi wylicza pozycje mimo, że wartość znalazłem wynosi 1, a raz nie wylicza. |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 728 Pomógł: 76 Dołączył: 12.06.2009 Ostrzeżenie: (0%) ![]() ![]() |
|
|
|
![]() ![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 243 Pomógł: 1 Dołączył: 1.06.2010 Ostrzeżenie: (0%) ![]() ![]() |
Nie wiem ale wydaje mi się, że coś pokręciłeś sądząc, iż uzyskam to z curl_getinfo .
Gdzie mam szukać tych informacji ? Który indeks w tablicy daje takie informacje ? Zakładam,że strona może się wczytać do połowy co w moim przypadku daje błąd. Kod Array ( [url] => url="http://www.google.pl/search?hl=pl&q=sklep+meblowy&num=10" [content_type] => text/html; charset=ISO-8859-2 [http_code] => 200 [header_size] => 720 [request_size] => 201 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 1.977488 [namelookup_time] => 5.5E-5 [connect_time] => 0 [pretransfer_time] => 0.243076 [size_upload] => 0 [size_download] => 46923 [speed_download] => 23728 [speed_upload] => 0 [download_content_length] => -1 [upload_content_length] => 0 [starttransfer_time] => 0.760662 [redirect_time] => 0 ) Nie rozumiem dlaczego : $rezultat zwraca mi puste tablice : Kod <pre>Array ( [0] => Array ( ) [1] => Array ( ) ) </pre> podczas gdy w drugim przebiegu pętli jest już tak: Kod ( [0] => Array ( [0] => <h3 class="r"><a href="http://www.x-kom.pl/kontakt" class=l> [1] => <h3 class="r"><a href="http://www.tg.net.pl/katalog/_miasto_komputery.htm" class=l> [2] => <h3 class="r"><a href="http://www.tg.net.pl/katalog/_miasto_sklepy_internetowe.htm" class=l> [3] => <h3 class="r"><a href="http://www.proline.pl/?p=TG+TG530-U15+OEM" class=l> [4] => <h3 class="r"><a href="http://www.proline.pl/?p=TG%2BTG780-BZII%2BOEM" class=l> [5] => <h3 class="r"><a href="http://mcs.pc.pl/produkt1511.html" class=l> [6] => <h3 class="r"><a href="http://mcs.pc.pl/produkt1512.html" class=l> [7] => <h3 class="r"><a href="http://olimp.sklep.pl/produkt/71147,tp-link-tg-3269-karta-sieciowa-pci-10-100-1000mbps" class=l> [8] => <h3 class="r"><a href="http://komputery-sklep.com.pl/produkt/telefon_panasonic_kx-tg_1381_10379.html" class=l> [9] => <h3 class="r"><a href="http://www.uno.pl/t_27599/kx-tg_8070/" class=l> [10] => <h3 class="r"><a href="http://www.pc-abc.pl/" class=l> [11] => <h3 class="r"><a href="http://etcomputers.pl/okapy-kuchenne/163531-okap-kominowy-samsung-hdc-6475-tg.html" class=l> [12] => <h3 class="r"><a href="http://internetowy-sklep-komputerowy.skaner.com.pl/index.php?PHPSESSID=&akcja=03&artykul=000297" class=l> [13] => <h3 class="r"><a href="http://www.simplynet.pl/" class=l> [14] => <h3 class="r"><a href="http://www.harp.net.pl/" class=l> [15] => <h3 class="r"><a href="http://www.firmy.net/komputery-i-internet,tarnowskie-gory.html?p=4" class=l> [16] => <h3 class="r"><a href="http://sklep.kg.net.pl/produkt/56384/okap-kominowy-samsung-hdc-9475-tg" class=l> [17] => <h3 class="r"><a href="http://www.bitcomputer.pl/product.php?id=9430" class=l> [18] => <h3 class="r"><a href="http://www.webkupiec.pl/a/lista_produktow/idx/1050400/mot/Kx_tg_7200/lista_produktow.htm" class=l> [19] => <h3 class="r"><a href="http://www.geoinf.pl/produkt/AGDTKAZLE0008,Zlewozmywak-TEKA-UNIVERSO-60-B-TG-ONYKS" class=l> ) [1] => Array ( [0] => http://www.x-kom.pl/kontakt [1] => http://www.tg.net.pl/katalog/_miasto_komputery.htm [2] => http://www.tg.net.pl/katalog/_miasto_sklepy_internetowe.htm [3] => http://www.proline.pl/?p=TG+TG530-U15+OEM [4] => http://www.proline.pl/?p=TG%2BTG780-BZII%2BOEM [5] => http://mcs.pc.pl/produkt1511.html [6] => http://mcs.pc.pl/produkt1512.html [7] => http://olimp.sklep.pl/produkt/71147,tp-link-tg-3269-karta-sieciowa-pci-10-100-1000mbps [8] => http://komputery-sklep.com.pl/produkt/telefon_panasonic_kx-tg_1381_10379.html [9] => http://www.uno.pl/t_27599/kx-tg_8070/ [10] => http://www.pc-abc.pl/ [11] => http://etcomputers.pl/okapy-kuchenne/163531-okap-kominowy-samsung-hdc-6475-tg.html [12] => http://internetowy-sklep-komputerowy.skaner.com.pl/index.php?PHPSESSID=&akcja=03&artykul=000297 [13] => http://www.simplynet.pl/ [14] => http://www.harp.net.pl/ [15] => http://www.firmy.net/komputery-i-internet,tarnowskie-gory.html?p=4 [16] => http://sklep.kg.net.pl/produkt/56384/okap-kominowy-samsung-hdc-9475-tg [17] => http://www.bitcomputer.pl/product.php?id=9430 [18] => http://www.webkupiec.pl/a/lista_produktow/idx/1050400/mot/Kx_tg_7200/lista_produktow.htm [19] => http://www.geoinf.pl/produkt/AGDTKAZLE0008,Zlewozmywak-TEKA-UNIVERSO-60-B-TG-ONYKS ) ) </pre> W obydwu wypadkach strona się wczytała , a [http_code] = 200 + sprawdzanie o którym pisałem wcześniej. Dlaczego wartość zmiennej rezultat jest pusta pomimo , że kod się wgrywa i inne funkcje preg_match_all wyłapują wczytany kod ? Rde chyba znalazłem przyczynę: Oto kod jaki pojawia mi się po wczytaniu strony google. Kod <pre><!doctype html><head><title>sklep komputerowy tg - Szukaj w Google</title><script>window.google={kEI:"uJIfTcq1MYaKlweGxP3WDA",kEXPI:"0",kCSI:{e:"0",ei:"uJIfTcq1MYaKlweGxP3WDA",expi:"0"},ml:function(){},kHL:"pl",time:function(){return(new Date).getTime()},log:function(c,d, b){var a=new Image,e=google,g=e.lc,f=e.li;a.onerror=(a.onload=(a.onabort=function(){delete g[f]}));g[f]=a;b=b||"/gen_204?atyp=i&ct="+c+"&cad="+d+"&zx="+google.time();a.src=b;e.li=f+1},lc:[],li:0,Toolbelt:{}}; window.google.sn="web";var i=window.google.timers={};window.google.startTick=function(a,b){i[a]={t:{start:(new Date).getTime()},bfr:!(!b)}};window.google.tick=function(a,b,c){if(!i[a])google.startTick(a);i[a].t[b]=c||(new Date).getTime()};google.startTick("load",true);try{}catch(v){} window.google.jsrt_kill=1; var _gjwl=location;function _gjuc(){var e=_gjwl.href.indexOf("#");if(e>=0){var a=_gjwl.href.substring(e);if(a.indexOf("&q=")>0||a.indexOf("#q=")>=0){a=a.substring(1);if(a.indexOf("#")==-1){for(var c=0;c<a.length;){var d=c;if(a.charAt(d)=="&")++d;var b=a.indexOf("&",d);if(b==-1)b=a.length;var f=a.substring(d,b);if(f.indexOf("fp=")==0){a=a.substring(0,c)+a.substring(b,a.length);b=c}else if(f=="cad=h")return 0;c=b}_gjwl.href="/search?"+a+"&cad=h";return 1}}}return 0}function _gjp(){!(window._gjwl.hash&& window._gjuc())&&setTimeout(_gjp,500)}; window._gjp && _gjp()</script><style id=gstyle>body{color:#000;margin:3px 0}body,#leftnav,#tbd,#atd,#tsf,#hidden_modes,#hmp{background:#fff}#gog{background:#fff}#gbar,#guser{font-size:13px;padding-top:1px !important}#gbar{float:left;height:22px}#guser{padding-bottom:7px !important;text-align:right}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbs,.gbm{background:#fff;left:0;position:absolute;text-align:left;visibility:hidden;z-index:1000}.gbm{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}.gb1{margin-right:.5em}#gbar .gbsup{color:#c00;font-size:9px;font-weight:normal;line-height:9px;margin-left:-.5em;margin-right:.5em;*margin-left:-.5em;*margin-right:.5em}.gb1,.gb3{zoom:1}.gb2{display:block;padding:.2em .5em}.gb2,.gb3{text-decoration:none;border-bottom:none}a.gb1,a.gb2,a.gb3,a.gb4{color:#00c !important}a.gb2:hover{background:#36c;color:#fff !important}a.gb1,a.gb2,a.gb3,.link{color:#2200C1!important}.ts{border-collapse:collapse}.ts td{padding:0}.ti,.bl,form,#res h3{display:inline}.ti{display:inline-table}#tads a.mblink,#tads a.mblink b,#tadsc a.mblink,#tadsc a.mblink b,#rhs a.mblink,#rhs a.mblink b{color:#2200C1!important}a:link,.w,#prs a:visited,#prs a:active,.q:active,.q:visited{color:#2200C1}.mblink:visited,a:visited{color:#551a8b}.vst:link{color:#551a8b}.cur,.b{font-weight:bold}.j{width:42em;font-size:82%}.s{max-width:42em}.sl{font-size:82%}#gb{text-align:right;padding:1px 0 7px;margin:0}.hd{position:absolute;width:1px;height:1px;top:-1000em;overflow:hidden}.gl,.f,.m,.c h2,#mbEnd h2,#tads h2,#tadsc h2,.descbox{color:#767676}.a,cite,cite a:link,cite a:visited,.cite,.cite:link,#mbEnd cite b,#tads cite b,#tadsc cite b{color:#0e774a;font-style:normal}.ng{color:#c11}h1,ol,ul,li{margin:0;padding:0}li.g,body,html,.std,.c h2,#mbEnd h2,h1{font-size:small;font-family:arial,sans-serif}.c h2,#mbEnd h2,h1{font-weight:normal}.clr{clear:both;margin:0 8px}.blk a{color:#000}#nav a{display:block}#nav .i{color:#a90a08;font-weight:bold}.csb,.ss,#logo span,.play_icon,.mini_play_icon,.micon,.licon,.close_btn,#tbp,.lsb,.mbi{backgrou nd:url(/images/srpr/nav_logo27.png) no-repeat;overflow:hidden}.csb,.ss{background-position:0 0;height:40px;display:block}.ss{background-position:0 -91px;position:absolute;left:0;top:0}.cps{height:18px;overflow:hidden;width:114px}.mbi{background-position:-153px -70px;display:inline-block;float:left;height:13px;margin-right:3px;margin-top:1px;width:13px}#nav td{padding:0;text-align:center}#logo{display:block;overflow:hidden;position:relative;width:137px;height:49px;margin:9px 0 0}#logo img{border:none;position:absolute;left:-0px;top:-41px}#logo span,.ch{cursor:pointer}h3,.med{font-size:medium;font-weight:normal;padding:0;margin:0}.e{margin:2px 0 .75em}.slk div{padding-left:12px;text-indent:-10px}.fc{margin-top:.5em;padding-left:16px}#mbEnd cite{display:block;text-align:left}#rhs_block{margin-bottom:-20px}#bsf,.blk{border-top:1px solid #6b90da;background:#f0f7f9}#bsf{border-bottom:1px solid #6b90da}#cnt{clear:both}#res{padding-right:1em;margin:0 16px}.c{background:#fbf0fa;margin:0 8px}.c li{padding:0 3px 0 8px;margin:0}#mbEnd li{margin:1em 0;padding:0}.xsm{font-size:x-small}ol li{list-style:none}#ncm ul li{list-style-type:disc}.sm li{margin:0}.gl,#foot a,.nobr{white-space:nowrap}#mbEnd .med{white-space:normal}.sl,.r{display:inline;font-weight:normal;margin:0}.r{font-size:medium}h4.r{font-size:small}.mr{margin-top:6px}h3.tbpr{margin-top:.4em;margin-bottom:1.2em}img.tbpr{border:0px;width:15px;height:15px;margin-right:3px}.jsb{display:block}.nojsb{display:none}.nwd{font-size:10px;padding:16px;text-align:center}.rt1{background:transparent url(/images/bubble1.png) no-repeat}.rt2{background:transparent url(/images/bubble2.png) repeat 0 0 scroll}.sb{background:url(/images/scrollbar.png) repeat scroll 0 0;cursor:pointer;width:14px}.rtdm:hover{text-decoration:underline}#rtr .g{margin:1em 0}#ss-box{background:#fff;border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;left:0;margin-top:.1em;position:absolute;visibility:hidden;z-index:101}#ss-box a{display:block;padding:.2em .31em;text-decoration:none}#ss-box a:hover{background:#558be3;color:#fff!important}a.ss-selected{color:#000!important;font-weight:bold}a.ss-unselected{color:#4273db!important}.ss-selected .mark{display:inline}.ss-unselected .mark{visibility:hidden}#ss-barframe{background:#fff;left:0;position:absolute;visibility:hidden;z-index:100}.ri_cb{left:0;margin:6px;position:absolute;top:0;z-index:1}.ri_sp{display:-moz-inline-box;display:inline-block;text-align:center;vertical-align:top;margin-bottom:6px}.ri_sp img{vertical-align:bottom}.popup-cont{background:#fff;border:1px solid #ccc;display:none;padding:15px;position:absolute;visibility:hidden;width:450px;z-index:1000}.popup-display{display:inline}.popup-close{background:transparent url(/products/images/popup-sprite.png) no-repeat -90px 0;cursor:pointer;height:12px;overflow:hidden;position:absolute;right:10px;top:10px;width:12px}.popup-title{font-size:124%;font-weight:bold;padding-bottom:3px}.ps-map{float:left}.popup-arrow{background:transparent url(/products/images/popup-sprite.png) no-repeat 0 0;overflow:hidden;position:absolute}.popup-arrow-top{background-position:-46px -23px;height:23px;left:20px;top:-23px;width:44px}.popup-arrow-bottom{background-position:-46px 0;bottom:-23px;height:23px;left:20px;width:44px}.popup-arrow-bottomright{background-position:-46px 0;bottom:-23px;height:23px;right:20px;width:44px}.popup-arrow-left{height:44px;left:-23px;top:20px;width:23px}.popup-arrow-right{background-position:-23px 0;height:44px;right:-23px;top:20px;width:23px}.ps-map img{border:1px solid #00c}a.tiny-pin,a.tiny-pin:link,a.tiny-pin:hover{text-decoration:none;color:#4272DB}a.tiny-pin:hover span{text-decoration:underline}.tiny-pin table{vertical-align:middle}.tiny-pin p{background-image:url(/images/srpr/nav_logo27.png);background-position:-117px -91px;height:15px;margin:0;padding:0;top:-1px;overflow:hidden;position:relative;width:9px;}.loc-list-cont{margin-left:200px}body .locations-table td{background:#fff;padding:3px;vertical-align:top}.pspa-price{font-size:medium;font-weight:bold}.pspa-call-price{font-size:small;font-weight:bold}.pspa-store-avail{color:#282}.pspa-out-of-stock{color:#c11}.mbl{margin:1em 0 0} skróciłem kod h2{color:#767676}#mbEnd li{margin:12px 0 0}a:link,.w,.q:active,.q:visited,.tbotu{color:#2200C1;cursor:pointer}a.fl:link,.fl a,.flt,a.flt,.gl a:link,a.mblink,.mblink b{color:#4272db}.osl a,.gl a,#tsf a,a.mblink,a.gl,a.fl,.slk a,.bc a,.flt,a.flt u,.oslk a{text-decoration:none}.osl a:hover,.gl a:hover,#tsf a:hover,a.mblink:hover,a.gl:hover,a.fl:hover,.slk a:hover,.bc a:hover,.flt:hover,a.flt:hover u,.oslk a:hover,.tbotu:hover{text-decoration:underline}#ss-box a:hover{text-decoration:none}#tads .mblink,#tadsc .mblink,#rhs .mblink{text-decoration:underline}.hpn,.osl{color:#767676}div#gbi,div#gbg{border-color:#a2bff0 #558be3 #558be3 #a2bff0}div#gbi a.gb2:hover,div#gbg a.gb2:hover,.mi:hover{background-color:#558be3}#guser a.gb2:hover,.mi:hover,.mi:hover *{color:#fff!important}#guser{color:#000}#imagebox_big img{padding:2px!important}#productbox .fmg{margin-top:7px;padding-right:8px;text-align:left}#foot .ftl{margin-right:12px}#foot a.slink{text-decoration:none;color:#4272db}#fll a,#bfl a{color:#4272db;margin:0 12px;text-decoration:none}#foot a:hover{text-decoration:underline}#foot a.slink:visited{color:#551a8b}#blurbbox_bottom{color:#767676}.nvs a{text-decoration:underline}.stp{margin:7px 0 17px}.ssp{margin:.33em 0 17px}#mss {margin:.33em 0 0;padding:0;display:table}.mss_col {display:inline-block;float:left;font-size:small;white-space:nowrap;padding-right:16px;}#mss p{margin:0;padding-top:5px}#gsr a:active,a.fl:active,.fl a:active,.gl a:active{color:#c11}.obsmo #obsmtxt, #obsltxt{display:none}.obsmo #obsltxt{display:inline}#obsmtc a{text-decoration:none}#obsmtc a:hover{text-decoration:underline}</style><noscript><style>.jsb{display:none}.nojsb{display:block}.nojsv{visibility:visible}</style></noscript><script>google.y={};google.x=function(e,g){google.y[e.id]=[e,g];return false};window.gbar={qs:function(){},tg:function(e){var o={id:'gbar'};for(i in e)o[i]=e[i];google.x(o,function(){gbar.tg(o)})}};</script></head><body id=gsr topmargin=3 marginheight=3><textarea id=csi style=display:none> Widać, strona się wczytała i są niej wyrażenia "google.pl". Nie ma w niej natomiast wyników wyszukiwania , które chcę odczytać. Ciekawe dlaczego ? Ten post edytował fiasko 1.01.2011, 21:38:30 |
|
|
![]() ![]() |
![]() |
Aktualny czas: 25.08.2025 - 16:27 |