測試環境 Windows 10
平時在 Linux 環境下會使用 curl (簡易文字版瀏覽器) , 在 Windows 下可以透過 PowerShell 的 Invoke-WebRequest 指令.
PS C:\Users\Ben> Invoke-WebRequest -URI https://www.google.com StatusCode : 200 StatusDescription : OK Content : <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="zh-TW"><head><meta con tent="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1 x/... RawContent : HTTP/1.1 200 OK Cross-Origin-Opener-Policy-Report-Only: same-origin-allow-popups; report-to="gws" Report-To: {"group":"gws","max_age":2592000,"endpoints":[{"url":"https://csp.withgoogle.com/csp/rep o... Forms : {f} Headers : {[Cross-Origin-Opener-Policy-Report-Only, same-origin-allow-popups; report-to="gws"], [Report-To, { "group":"gws","max_age":2592000,"endpoints":[{"url":"https://csp.withgoogle.com/csp/report-to/gws/o ther"}]}], [X-XSS-Protection, 0], [X-Frame-Options, SAMEORIGIN]...} Images : {@{innerHTML=; innerText=; outerHTML=<IMG id=hplogo style="PADDING-BOTTOM: 14px; PADDING-TOP: 28px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px" alt=Google src="/images/branding/googlelogo/1x/googlelogo_w hite_background_color_272x92dp.png" width=272 height=92>; outerText=; tagName=IMG; id=hplogo; style =PADDING-BOTTOM: 14px; PADDING-TOP: 28px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; alt=Google; src=/i mages/branding/googlelogo/1x/googlelogo_white_background_color_272x92dp.png; width=272; height=92}} InputFields : {@{innerHTML=; innerText=; outerHTML=<INPUT type=hidden value=zh-TW name=hl>; outerText=; tagName=I NPUT; type=hidden; value=zh-TW; name=hl}, @{innerHTML=; innerText=; outerHTML=<INPUT type=hidden va lue=hp name=source>; outerText=; tagName=INPUT; type=hidden; value=hp; name=source}, @{innerHTML=; innerText=; outerHTML=<INPUT type=hidden name=biw>; outerText=; tagName=INPUT; type=hidden; name=bi w}, @{innerHTML=; innerText=; outerHTML=<INPUT type=hidden name=bih>; outerText=; tagName=INPUT; ty pe=hidden; name=bih}...} Links : {@{innerHTML=<SPAN class=gbtb2></SPAN><SPAN class=gbts>搜尋</SPAN>; innerText=搜尋; outerHTML=<A id =gb_1 class="gbzt gbz0l gbp1" href="https://www.google.com.tw/webhp?tab=ww"><SPAN class=gbtb2></SPA N><SPAN class=gbts>搜尋</SPAN></A>; outerText=搜尋; tagName=A; id=gb_1; class=gbzt gbz0l gbp1; href =https://www.google.com.tw/webhp?tab=ww}, @{innerHTML=<SPAN class=gbtb2></SPAN><SPAN class=gbts>圖 片</SPAN>; innerText=圖片; outerHTML=<A id=gb_2 class=gbzt href="https://www.google.com.tw/imghp?hl =zh-TW&tab=wi"><SPAN class=gbtb2></SPAN><SPAN class=gbts>圖片</SPAN></A>; outerText=圖片; tagNa me=A; id=gb_2; class=gbzt; href=https://www.google.com.tw/imghp?hl=zh-TW&tab=wi}, @{innerHTML=< SPAN class=gbtb2></SPAN><SPAN class=gbts>地圖</SPAN>; innerText=地圖; outerHTML=<A id=gb_8 class=gb zt href="https://maps.google.com.tw/maps?hl=zh-TW&tab=wl"><SPAN class=gbtb2></SPAN><SPAN class= gbts>地圖</SPAN></A>; outerText=地圖; tagName=A; id=gb_8; class=gbzt; href=https://maps.google.com. tw/maps?hl=zh-TW&tab=wl}, @{innerHTML=<SPAN class=gbtb2></SPAN><SPAN class=gbts>Play</SPAN>; in nerText=Play; outerHTML=<A id=gb_78 class=gbzt href="https://play.google.com/?hl=zh-TW&tab=w8"> <SPAN class=gbtb2></SPAN><SPAN class=gbts>Play</SPAN></A>; outerText=Play; tagName=A; id=gb_78; cla ss=gbzt; href=https://play.google.com/?hl=zh-TW&tab=w8}...} ParsedHtml : mshtml.HTMLDocumentClass RawContentLength : 48172
如果只需要看 Content ,可以透過以下方式.
PS C:\Users\Ben> curl -Uri https://www.google.com | Select-Object -ExpandProperty Content
如果是要看該網站有提供那些連結,可以透過以下的方式.
PS C:\Users\Ben> (Invoke-WebRequest -Uri "https://www.google.com/").Links.Href https://www.google.com.tw/webhp?tab=ww https://www.google.com.tw/imghp?hl=zh-TW&tab=wi https://maps.google.com.tw/maps?hl=zh-TW&tab=wl https://play.google.com/?hl=zh-TW&tab=w8 https://www.youtube.com/?tab=w1 https://news.google.com/?tab=wn https://mail.google.com/mail/?tab=wm https://drive.google.com/?tab=wo https://www.google.com.tw/intl/zh-TW/about/products?tab=wh https://calendar.google.com/calendar?tab=wc https://translate.google.com.tw/?hl=zh-TW&tab=wT https://books.google.com.tw/?hl=zh-TW&tab=wp https://www.google.com.tw/shopping?hl=zh-TW&source=og&tab=wf https://www.blogger.com/?tab=wj https://www.google.com/finance?tab=we https://photos.google.com/?tab=wq&pageId=none http://video.google.com.tw/?hl=zh-TW&tab=wv https://docs.google.com/document/?usp=docs_alc https://www.google.com.tw/intl/zh-TW/about/products?tab=wh https://accounts.google.com/ServiceLogin?hl=zh-TW&passive=true&continue=https://www.google.com/&ec=GAZAAQ http://www.google.com.tw/preferences?hl=zh-TW /preferences?hl=zh-TW http://www.google.com.tw/history/optout?hl=zh-TW /advanced_search?hl=zh-TW&authuser=0 http://www.google.com.tw/intl/zh-TW/services/ /intl/zh-TW/about.html https://www.google.com/setprefdomain?prefdom=TW&prev=https://www.google.com.tw/&sig=K_zgI19El6kagUSYWLB1UOgVCnzNU%3D /intl/zh-TW/policies/privacy/ /intl/zh-TW/policies/terms/
沒有解決問題,試試搜尋本站其他內容