0

Code:

import org.jsoup.Jsoup
fun main(){
    val url = "https://www.google.com/maps/place/?q=place_id:"
    //val placeID:String = "ChIJRVY_etDX3IARGYLVpoq7f68";
    val placeID:String = "ChIJ1zoUGxYE9YgRL399jlxWp6Q";
    val doc = Jsoup.connect(url+placeID).get()
    val text = doc.html()
    //println(text)

    when (text)
    {
        is String -> println("yay");
    }
    //val pID: Collection<String>? = placeID as? String

    //val here: Pair<Int, String>? = text.findLastAnyOf(placeID,0,false);
    var tempLine:String = ""
    tempLine = text.substringAfterLast(placeID)
    val newLength = tempLine.length
    var tempLine2 = tempLine.substringBefore("window.APP_FLAGS")
    println(tempLine2)
}

Output.jpg

The text I want to specifically grab and return

I am working on a personal side project and I have hit a wall, where I cannot grab the busy time information from Google's page, this location is Trader Joes.

wots
  • 1
  • Did you try Regex to get the text between `null,[[` and `\n` – Jagar Mar 27 '21 at 05:38
  • @Jagar I commented out println(tempLine2) and added this code: `val busyPattern = "..[\\d],[\\d],............[\\d] [A-Z][A-Z]".toRegex() val matches = busyPattern.findAll(tempLine2) println(matches)` Unfortunately my output is now: kotlin.sequences.GeneratorSequence@a38d7a3 – wots Mar 27 '21 at 08:40
  • Please find here the first example to how correctly apply regex patterns in Kotlin: https://stackoverflow.com/a/34595791/12053756 – Jagar Mar 27 '21 at 08:53

0 Answers0