質問に失礼があったらすみません。
数時間調べても似たエラーのループで解決しなかったので質問致しました。Scalaは勉強中です。よろしくお願いします。
ScalaでJsoupを使ってJリーグのサイトのHTMLを解析したいのですが、ためしに適当にIdを指定してFor文で回そうと思ったのですが、うまくいかないため質問いたしました。
なんとか回避しようと以下のサイトを参考にしました
https://jsoup.org/apidocs/org/jsoup/select/Elements.html#forms--
http://www.mwsoft.jp/programming/scala/foreach.html
http://www.ne.jp/asahi/hishidama/home/tech/scala/array.html
以下のコードを実行すると下記のようなエラーが発生します。
type mismatch; found : Unit required: String
Scala
1package controllers 2 3import play.api._ 4import play.api.mvc._ 5 6import org.jsoup._ 7import collection.JavaConverters._ 8 9object Application extends Controller { 10 11 def index = Action { 12 testget() 13 Ok(views.html.index("Your new application is ready.")) 14 } 15 16 def getTest(urlstr: String):String = { 17 18 // URLからHTML取得 19 val doc = Jsoup.connect(urlstr).get 20 val stoksPrices = doc.select("td[class=nowrap]"); 21 //val stoksPrice = stoksPrices.get(0) 22 //return stoksPrice.text 23 for(i:(Int) <- 0 to (stoksPrices.forms().size:(Int)))( 24 stoksPrices.get(i).text 25 ) 26 //(0 to stoksPrices.size).foreach(stoksPrices.get(_:Int).text) 27 28 } 29 30 def testget() { 31 val stoksPrice = getTest("https://data.j-league.or.jp/SFMS01/search?competition_years=2016") 32 println(stoksPrice) 33 } 34
回答1件
あなたの回答
tips
プレビュー