3
我無法通過http代理從scala中的URL讀取。Scala的Source.fromURL通過http代理
我有這樣的代碼
//This is just to print the environment
import scala.collection.JavaConversions._
println(System.getProperties.filter(_._1 startsWith("http")).toList sortBy(_._1) mkString "\n")
import scala.io.Source
val html = Source.fromURL("http://google.com")
val s = html.mkString
println(s)
我收到以下錯誤
(http.proxyHost,158.169.9.13)
(http.proxyPassword,*****)
(http.proxyPort,8012)
(http.proxyUser,*****)
java.io.IOException: Server returned HTTP response code: 407 for URL: http://google.com
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1612)
at java.net.URL.openStream(URL.java:1035)
at scala.io.Source$.fromURL(Source.scala:143)
at scala.io.Source$.fromURL(Source.scala:133)
at Main$$anon$1.<init>(download.scala:7)
at Main$.main(download.scala:1)
at Main.main(download.scala)
我期待google.com的頁面源代碼的打印。