i want to get the view source of this page "http://localhost:3000/splash_templates/edit_template/10017".
我使用httpclient gem,但是這是獲取登錄頁面的視圖源。 那麼如何設置身份驗證以及如何獲得查看源如何在rails中動態獲取頁面的視圖源
i want to get the view source of this page "http://localhost:3000/splash_templates/edit_template/10017".
我使用httpclient gem,但是這是獲取登錄頁面的視圖源。 那麼如何設置身份驗證以及如何獲得查看源如何在rails中動態獲取頁面的視圖源
我以前沒有使用它,但需要先驗證用戶身份,然後獲取內容。
http://www.rubydoc.info/gems/httpclient/2.1.5.2/HTTPClient此網址將幫助你。 Configuring authentication credentials
部分提供授權用戶運行時的方式。
希望這對你有所幫助!
只有鏈接的答案沒有幫助。請將鏈接中找到的相關信息複製到您的答案中。 – Substantial 2014-10-20 21:22:22
您需要登錄才能獲取頁面的來源。 雖然你的問題是不明確的,以請求要設置什麼樣的身份驗證,但是這裏的提示,你可以用
Authentication with Web server. Supports BasicAuth, DigestAuth, and Negotiate/NTLM (requires ruby/ntlm module).
clnt = HTTPClient.new
domain = 'http://dev.ctor.org/http-access2/'
user = 'user'
password = 'user'
clnt.set_auth(domain, user, password)
p clnt.get_content('http://dev.ctor.org/http-access2/login').status
先走你可以閱讀更多關於這個Here
。希望幫助;)
你google了嗎?或者至少通過了httpClient的圖書館文件? – 2014-10-20 06:38:30