php 如何獲取遠端 網頁的大小

2025-05-28 11:10:23 字數 2890 閱讀 1072

1樓:

用curl 有個地方要注意 curl_setopt($ch, curlopt_header, 1);

他就會返回請求頭,比如。

http/ 200 ok

date: thu, 05 may 2011 09:51:14 gmt

server: microsoft-iis/

pragma: no-cache

cache-control: private

x-powered-by:

x-aspnet-version:

cache-control: private, max-age=0

content-type: text/xml; charset=utf-8

content-length: 274

content-length: 274就是請求大小,curl怎麼用不用給**了吧 網上一堆。

哎呀不好意思試了下那個**沒有返回content-length,不過這也是個方法吧。

怎麼用php獲取網頁的大小

2樓:註冊好勒

沒有長度的。

get / http/

accept: *

accept-language: zh-cn

accept-encoding: gzip, deflate

if-modified-since: tue, 22 aug 2006 05:57:16 gmt; length=204198

user-agent: mozilla/ (compatible; msie ; windows nt ; sv1; .net clr

host:connection: keep-alive

所以要指明這是我的請求和接受。

up:get / http/

accept:*/

user-agent:mozilla/ (compatible; msie ; windows 2003)

connection:keep-alive

3樓:網友

用curl 有個地方要注意 curl_setopt($ch, curlopt_header, 1);

他就會返回請求頭,比如。

http/ 200 ok

date: thu, 05 may 2011 09:51:14 gmt

server: microsoft-iis/

pragma: no-cache

cache-control: private

x-powered-by:

x-aspnet-version:

cache-control: private, max-age=0

content-type: text/xml; charset=utf-8

content-length: 274

content-length: 274就是請求大小,curl怎麼用一下就知道了,很多。

4樓:網友

用js不更好?啥都用php去搞,多單調!

php獲取遠端檔案的大小

5樓:網友

你的**很正確,無可挑剔,再除錯一遍。

6樓:西安小孔

沒有php專區,只好貼到這來了,不要給我其它語言的**,只要php的___不會php

php獲取遠端頁面html

7樓:網友

file_get_contents()比file()慢?

如果抓取別人的頁面還是用file_get_contents()比較好~

file()取回的是陣列。

而file_get_contents()取回的是字串你是想取回個陣列再把它們連起來方便?還是直接把他們取回來方便?

另外file_get_contents(string,int)有個可選引數設定讀取的長度。

在php手冊中說:

file_get_contents() 函式是用來將檔案的內容讀入到乙個字串中的首選方法。如果作業系統支援還會使用記憶體對映技術來增強效能。

8樓:網友

file_get_contents直接返回字串,不必一行一行的讀取陣列。

echo $str;

php獲取網頁(sina)大小,載入時間?

9樓:陽光上的橋

負值的猛兄原因我也枝塌襲不清楚,可以看看$time1、$time2的值,如果裡面的秒部分為0,可能是系統衫櫻不支援。

關於php頁面獲取php頁面內容的問題

10樓:網友

按照你的引用,生成的**是沒有進行儲存,而是直接輸出的**格式。

這種情況下你可以通過另外乙個php來獲取生成的**,然後儲存!

php怎樣偽造來路獲取遠端網頁,

11樓:網友

獲取網頁內容。

file_get_contents()

函式就行了,不懂可以看手冊。

當然還有其他方法,curl 也可以。

php高手進 php獲取當前時間 如何判斷大小

12樓:小甲的殼

$date_1=date("m-d-y h:i:s");

date_2="08-12-2006 09:12:34";

d1=strtotime($date_1);

d2=strtotime($date_2);

if($d1<$d2)

補充:你遇到的問題無法再現。

php獲取ip地址的函式區別,php獲取IP地址的三個函式區別

三者比較如下 server remote addr 取得客戶端的 ip 地址 通過 伺服器取得客戶端的真實 ip 地址 server http client ip 獲取客戶端,及瀏覽器所在的電腦的ip地址 以下資料供參考 1 remote addr 瀏覽當前頁面的使用者計算機的ip地址 瀏覽當前頁面...

如何用php獲取rabbitmq指定佇列中的未處理訊息數量

lare一個佇列,置amqp passive標誌位,就不會影響服務端狀態,並返回訊息計數。conn new amqpconnection queue new amqpqueue conn queue setflags amqp passive messagecount queue declare q...

PHP抓取網頁指定內容,php獲取指定網頁內容

rt 用file get contents 內容地址 之後用正則來匹配你要得到的內容 這個直接用樂思採集系統就可以搞定 php獲取指定網頁內容 一 用file get contents函式,以post方式獲取url 二 用file get contents以get方式獲取內容 三 用fopen開啟u...