百度搜索資源平臺 https://ziyuan.baidu.com/?cas...html
連接提交地址 https://ziyuan.baidu.com/link...html5
百度爬蟲 UAnode
- Mozilla/5.0 (Linux;u;Android 4.2.2;zh-cn;) AppleWebKit/534.46 (KHTML,like Gecko) Version/5.1 Mobile Safari/10600.6.3 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/s...
- Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/s...)
Google Search Console https://search.google.com/sea...nginx
谷歌爬蟲 UAweb
- Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
信息架構要明晰,這個對 SEO 也很是重要,包括網站扁平化設計,友好的 URL 設計,標題書寫,頁面相關度信息聚合和融合,這也是影響用戶體驗的一大部分。segmentfault
爲網站肯定一個主題(核心關鍵詞),一旦肯定,那麼全站都圍繞這個關鍵詞進行擴展和相關性來作瀏覽器
網站外鏈就是在別的網站導入本身網站的連接,高質量高 PR 的外鏈能迅速提升自身網站的權重。友鏈則是本身的網站包含了其餘網站的連接,效果與外鏈相似。緩存
Meta 標籤用於給搜索引擎提供關於網頁的信息,這些信息對於訪問者而言是不可見的。安全
參考淘寶網的作法服務器
<header> <title>淘寶網 - 淘!我喜歡</title> <meta name="description" content="淘寶網 - 亞洲較大的網上交易平臺,提供各種服飾、美容、家居、數碼、話費/點卡充值… 數億優質商品,同時提供擔保交易(先收貨後付款)等安全交易保障服務,並由商家提供退貨承諾、破損補寄等消費者保障服務,讓你安心享受網上購物樂趣!" /> <meta name="keyword" content="淘寶,掏寶,網上購物,C2C,在線交易,交易市場,網上交易,交易市場,網上買,網上賣,購物網站,團購,網上貿易,安全購物,電子商務,放心買,供應,買賣信息,網店,一口價,拍賣,網上開店,網絡購物,打折,免費開店,網購,頻道,店鋪" /> ... </header>
Meta - Robots
robots 管理着搜索引擎是否能夠進入網頁
以下面一段代碼,禁止搜索引擎獲取網頁,而且阻止其進入連接。
<meta name="」robots」" content="」noindex," nofollow」 />
爬蟲訪問時,會使用特殊的 user agent,以百度蜘蛛的 UA 爲例,它會使用「Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/s...)」這樣的UA,因此咱們能夠判斷 UA 中含有「Baiduspider」字樣則意味着是百度蜘蛛來訪問了
先把靜態頁放置到網站的 /assets/static/ 下,配置 nginx 的配置文件 nginx.conf:
location / { root C:\projects\bzbclub-dist; index index.html index.htm; if ( $http_user_agent ~* "Baiduspider"){ rewrite ^/index.html$ /assets/static/index.html last; } }
保存配置文件後要使用 nginx -s reload 從新加載網站,而後使用 curl 命令的「-A」參數模擬百度蜘蛛訪問首頁:
curl -A "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/s...)" http://localhost:17082 > z:tempbzbclub.html
打開 z:tempbzbclub.html 確認是否已經返回了靜態頁的內容。
Phantom.js
var fs = require("fs"); var page = require("webpage").create(); phantom.outputEncoding = "utf-8"; //指定編碼方式 page.open("http://localhost:17082", function(status) { if (status === "success") { fs.write("z:\\temp\\index.html", page.content, "w"); } else { console.log("網頁加載失敗"); } phantom.exit(0); //退出系統 });
將此腳本保存爲「phantom-static-page.js」,在命令行執行此腳本:
phantomjs phantom-static-page.js
Puppeteer
const fs = require("fs"); const puppeteer = require("puppeteer"); (async () => { const browser = await puppeteer.launch({ headless: false // executablePath: "C:/Program Files (x86)/Google/Chrome" }); const page = await browser.newPage(); page.setViewport({ width: 1920, height: 1800 }); await page.goto("http://localhost:3333"); await page.screenshot({ path: "example.png" }); const content = await page.content(); fs.writeFileSync("./index.html", content); // await page.close(); // await browser.close(); })();
將此腳本保存爲「pupp-static-page.js」,在命令行執行此腳本:
node pupp-static-page.js
從瀏覽器獲取靜態頁內容(推薦)
與前二者相比,看上去沒那麼極客,可是很是的簡單好用。
static.html
F12
打開 DevTool<html>
標籤,右鍵 Copy > Copy OuterHTMLstatic.html
保存便可靜態頁壓縮優化
static.html
,刪除掉全部的<script></script>以及其中的內容F12
打開 DevTool 確保沒有報錯參考文章連接
《Meta 標籤與搜索引擎優化》
《SEO 網站優化的步驟和技巧有哪些?》
《Angular2 網站 SEO 攻略》