如何將 wget 檢索到的內容輸出到 stdout 並抑制所有其他 wget 訊息傳遞?

如何將 wget 檢索到的內容輸出到 stdout 並抑制所有其他 wget 訊息傳遞?

我在 Amazon Linux 上使用 bash shell。我在 shell 腳本中有一個命令

wget -O - "http://localhost:8088/subco/books/$e_id/segments/$segment_id?product=$product_id&audience=teacher" > /dev/null

正在讀這篇文章——https://superuser.com/questions/321240/how-do-you-redirect-wget-to-standard-out/321241,我被引導相信我可以將 wget 的結果(它檢索到的內容)輸出到我的螢幕並抑制所有其他輸出。然而,我得到的是

--2018-05-29 18:39:49--  http://localhost:8088/subco/books/C2644BB08F394E209A26175BD2C89F5A/segments/C2F62E7002964DD396E381DB331129A4?product=D399B9C5F6204EDE80A002930CC0D02F&audience=teacher
Resolving localhost (localhost)... 127.0.0.1
Connecting to localhost (localhost)|127.0.0.1|:8088... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘STDOUT’

如何將 wget 的結果輸出到螢幕並抑制所有其他資訊(例如「HTTP 請求已發送,等待回應... 200 OK」部分)?

答案1

如果你想使用 wget,請使用 -qO -

wget -qO - google.com 

或者你可以使用不含任何選項的curl

捲曲 google.com

如果你想更進一步並解析結果等,Python 的 BeautifulSoup 套件很棒。

相關內容