導航:首頁 > 編程大全 > 禁止網路爬蟲

禁止網路爬蟲

發布時間:2021-10-11 18:41:58

Ⅰ 如何對付網路爬蟲

可以設置robots.txt來禁止網路爬蟲來爬網站
方法:
首先,你先建一個空白文本文檔(記事本),然後命名為:robots.txt;
(1)禁止所有搜索引擎訪問網站的任何部分。
User-agent: *
Disallow: /
(2)允許所有的robots訪問,無任何限制。
User-agent: *
Disallow:
或者
User-agent: *
Allow: /
還可以建立一個空文件robots.txt或者不建立robots.txt。

(3)僅禁止某個搜索引擎的訪問(例如:網路spider)
User-agent: BaiSpider
Disallow:/
(4)允許某個搜索引擎的訪問(還是網路)
User-agent: BaiSpider
Disallow:
User-agent: *
Disallow: /
這里需要注意,如果你還需要允許谷歌bot,那麼也是在「User-agent: *」前面加上,而不是在「User-agent: *」後面。
(5)禁止Spider訪問特定目錄和特定文件(圖片、壓縮文件)。
User-agent: *
Disallow: /AAA.net/
Disallow: /admin/
Disallow: .jpg$
Disallow: .rar$
這樣寫之後,所有搜索引擎都不會訪問這2個目錄。需要注意的是對每一個目錄必須分開說明,而不要寫出「Disallow:/AAA.net/ /admin/」。

Ⅱ 如何禁止搜索引擎爬蟲抓取網站頁面

以下列舉了屏蔽主流搜索引擎爬蟲(蜘蛛)抓取/索引/收錄網頁的幾種思路。注意:是整站屏蔽,而且是盡可能的屏蔽掉所有主流搜索引擎的爬蟲(蜘蛛)。

1、通過 robots.txt 文件屏蔽
可以說 robots.txt 文件是最重要的一種渠道(能和搜索引擎建立直接對話),給出以下建議:
User-agent: Baispider
Disallow: /
User-agent: Googlebot
Disallow: /
User-agent: Googlebot-Mobile
Disallow: /
User-agent: Googlebot-Image
Disallow:/
User-agent: Mediapartners-Google
Disallow: /
User-agent: Adsbot-Google
Disallow: /
User-agent:Feedfetcher-Google
Disallow: /
User-agent: Yahoo! Slurp
Disallow: /
User-agent: Yahoo! Slurp China
Disallow: /
User-agent: Yahoo!-AdCrawler
Disallow: /
User-agent: YouBot
Disallow: /
User-agent: Sosospider
Disallow: /
User-agent: Sogou spider
Disallow: /
User-agent: Sogou web spider
Disallow: /
User-agent: MSNBot
Disallow: /
User-agent: ia_archiver
Disallow: /
User-agent: Tomato Bot
Disallow: /
User-agent: *
Disallow: /
2、通過 meta tag 屏蔽
在所有的網頁頭部文件添加,添加如下語句:
<meta name="robots" content="noindex, nofollow">
3、通過伺服器(如:Linux/nginx )配置文件設置
直接過濾 spider/robots 的IP 段。

Ⅲ 如何禁止所有搜索引擎蜘蛛的爬行收錄

可使用robots協議:建立robots.txt 文件,上傳至網站根目錄:

屏蔽所有搜索引擎爬取網站的語法:


User-agent:*

Disallow:/


允許所有搜索引擎爬取網站所有內容


User-agent:*

Disallow:


只禁止網路抓取你網站的內容


User-agent:Baispider

Disallow:/


只允許網路抓取你網站的內容


User-agent:Baispider

Disallow:

User-agent:*

disallow:/

Ⅳ 如何禁止360爬蟲抓取

是寫在robots協議裡面的
User-agent: 360Spider
Disallow: /

Ⅳ 如何禁止百度爬蟲

舉辦抓蟲大賽?
額,好多人都在檢舉的,也可以去知道投訴吧投訴
http://tousu..com/
對了,檢舉要三級以上才可以,為了減少惡意檢舉嘛

Ⅵ 如何禁止別人爬蟲小程序代碼

Robots.txt-禁止爬蟲
robots.txt用於禁止網路爬蟲訪問網站指定目錄。robots.txt的格式採用面向行的語法:空行、注釋行(以#打頭)、規則行。規則行的格式為:Field:value。常見的規則行:User-Agent、Disallow、Allow行。
User-Agent行
User-Agent:robot-name
User-Agent:*
Disallow和Allow行
Disallow:/path
Disallow:#空字元串,起通配符效果,全禁止
Allow:/path
Allow:#空字元串,起通配符效果,全允許
搜索引擎的User-Agent對應名稱

搜索引擎
User-Agent值
Googlegooglebot
網路spider
雅虎slurp
MSNmsnbot
Alexais_archiver
我在Linux上抓包觀察到的一些搜索引擎訪問記錄:
#tcpmp-n-nn-A-l-s1024'tcpport80'|grepUser-Agent
User-Agent:Mozilla/5.0(compatible;Googlebot/2.1;+http://www.google.com/bot.html)
User-Agent:Googlebot-Image/1.0
User-Agent:Feedfetcher-Google;(+http://www.google.com/feedfetcher.html;5subscribers;feed-id=4619555564728728616)
User-Agent:Mozilla/5.0(compatible;Sosospider/2.0;+http://help.soso.com/webspider.htm)
User-Agent:Mozilla/5.0(compatible;YouBot/1.0;http://www.you.com/help/webmaster/spider/;)
User-Agent:Mozilla/5.0(compatible;JikeSpider;+http://shoulu.jike.com/spider.html)
JikeSpider是即刻搜索(人民搜索)。
robots.txt的補充
如果你沒有對網站根目錄的寫入許可權(無法建立robots.txt文件),或你想要某個指定的網頁不被搜索引擎收錄,可以使用元標簽阻止爬蟲訪問:
<metaname="robots"content="noindex"><!--阻止所有爬蟲-->
<metaname="googlerobot"content="noindex"><!--阻止Google收錄-->
robots元標記的默認值為"index,follow",它的取值可以是(來自Google站長幫助):
noindex防止網頁被編入索引。nofollow防止googlebot從此頁面中跟蹤鏈接。noarchive防止Google顯示網頁的快照鏈接。noimageindex不被Google圖片搜索索引。
現實中的robots.txt
淘寶屏蔽網路
淘寶屏蔽了網路抓取(2008年9月),http://www.taobao.com/robots.txt的內容:
User-agent:Baispider
Disallow:/
User-agent:spider
Disallow:/
網路與360的搜索引擎之爭
2012年8月,360推出搜索引擎,並與網路發生正面沖突。網路工程師跑出來說360違反robots協議,偷竊網路內容。以網路知道為例,http://..com/robots.txt的內容大致是這樣:
User-agent:Baispider
Disallow:/w?
Allow:/
User-agent:Googlebot
User-agent:MSNBot
User-agent:Baispider-image
User-agent:YouBot
User-agent:Sogouwebspider
User-agent:Sogouinstspider
User-agent:Sogouspider2
User-agent:Sogoublog
User-agent:SogouNewsSpider
User-agent:SogouOrionspider
User-agent:JikeSpider
User-agent:Sosospider
Allow:/
User-agent:*
Disallow:/
也就是說對360爬蟲而言,應該走最後一條規則,也就是禁止抓取網路知道所有內容。但從360搜索看,有網路知道的內容。

Ⅶ 如何禁止蜘蛛爬行robot

這里要說明的是Robots.txt文件只能起到阻止搜索引擎索引。Robots.txt寫法1.如果你站點中的所有文件,都可以讓蜘蛛爬取、收錄的話,那麼語法這樣寫: User-agent: *Disallow:當然,如果你網站中全部的文件都可以讓搜索引擎索引的話,你也可以不管這個文件。 2.完全禁止搜索引擎來訪的Robots.txt文件寫法: User-agent: * Disallow: / 2.1.要禁止掉某個搜索引擎來訪的Robots.txt文件寫法: User-agent: Googlebot Disallow: / 3.網站中某個文件夾不希望讓搜索引擎收錄的Robots.txt文件寫法: User-agent: * Disallow: /admin/ Disallow: /images/ 4.禁止Google抓取網站中的圖片文件: User-agent: Googlebot

Ⅷ 如何禁止網路爬蟲頻繁爬自己網站

在.htaccess里加入

RewriteCond %{REMOTE_HOST} ^123.456.789..*
RewriteRule ^.*$ X.html [L]

23.456.789 改為爬蟲地址。

Ⅸ 如何防止網站被爬蟲爬取的幾種辦法

相較於爬蟲技術,反爬蟲實際上更復雜。目前許多互聯網企業都會花大力氣進行「反爬蟲」,網路爬蟲不但會占據過多的網站流量,導致有真正需求的用戶沒法進入網站,另外也有可能會導致網站關鍵數據的外泄等現象。網路爬蟲遍布互聯網的各個角落,因此網路爬蟲有好處也有壞處,接下來介紹一下和網路爬蟲一同誕生的反爬蟲技術,如何才能防止別人爬取自己的網站?
1、基於程序本身去防止爬取:作為爬蟲程序,爬取行為是對頁面的源文件爬取,如爬取靜態頁面的html代碼,可以用jquery去模仿寫html,這種方法偽裝的頁面就很難被爬取了,不過這種方法對程序員的要求很高。
2、基於iptables和shell腳本:可以對nginx的access.log進行策略定義,例如定義在1分鍾內並發連接數超過30個ip為非法,如ip不在白名單內,則加入iptables策略封掉,當然這種的缺點是會有「誤傷」,策略細粒度越小就會有更多的「誤傷」,細粒度大就會使效果變差,另外還有類似的第三方工具fail2ban,利用做filter和actor對一些有危害的操作記錄或是封ip。但是對於某個特定的爬蟲地址(例如網易、有道)的爬取行為拒絕也很難准確做到,因為你無法准確知道這些特定的爬蟲ip地址。注意:建議不要用封ip條目的方式,iptables列表長度是65535時就會封滿,伺服器也就會死機。
3.使用robots.txt文件:例如阻止所有的爬蟲爬取,但是這種效果不是很明顯。
User-agent: *
Disallow: /
4.使用nginx的自帶功能:通過對httpuseragent阻塞來實現,包括GET/POST方式的請求,以nginx為例,具體步驟如下:
編輯nginx.conf
拒絕以wget方式的httpuseragent,增加如下內容
## Block http user agent - wget ##
if ($http_user_agent ~* (Wget) ) {
return 403;
}
## Block Software download user agents ##
if ($http_user_agent ~* LWP::Simple|BBBike|wget) {
return 403;

平滑啟動
# /usr/local/nginx/sbin/nginx -s reload
如何拒絕多種httpuseragent,內容如下:
if ($http_user_agent ~ (agent1|agent2|Foo|Wget|Catall Spider|AcoiRobot) ) {
return 403;
}
大小寫敏感匹配
### 大小寫敏感http user agent拒絕###
if ($http_user_agent ~ (Catall Spider|AcoiRobot) ) {
return 403;
}
### 大小寫不敏感http user agent拒絕###
if ($http_user_agent ~* (foo|bar) ) {
return 403;
}
注意語法:~*表示是大小寫不敏感,~表示是大小寫敏感

}
以上就是預防網站信息被別人爬取的一些方法,大量的爬取行為會對web伺服器的性能有影響,所以一定要注重反爬蟲措施。

閱讀全文

與禁止網路爬蟲相關的資料

熱點內容
原畫教程視頻 瀏覽:893
js精確到小數點後一位 瀏覽:565
python寫入excel數據時如何換行 瀏覽:794
有哪些視頻學習網站 瀏覽:383
蘋果u盤怎麼連接手機 瀏覽:336
文件資料管理台賬管理系統 瀏覽:804
macbookpro新建文件夾放哪裡 瀏覽:415
pvelite2015破解文件 瀏覽:960
汽車購票app叫什麼 瀏覽:288
linux網頁命令配置文件 瀏覽:289
wordpress換logo 瀏覽:249
編程序選哪個筆記本 瀏覽:716
保存cad為pdf時顯示文件不可編輯 瀏覽:68
郵箱版本收費版 瀏覽:798
下載的大文件放哪裡好 瀏覽:518
蘋果系統如何查找文件 瀏覽:21
遍歷txt資料庫 瀏覽:960
夾子文件夾 瀏覽:793
小新pad文件管理器在哪裡打開 瀏覽:945
閃照位於qq文件哪裡 瀏覽:441

友情鏈接