Closed xVemu closed 10 months ago
Please check relaxed parsing option as described here under point 4: https://docs.skrape.it/docs/dsl/extracting-data-from-websites
Still throws error in this scenario:
fun main() = runBlocking {
getLesson()
}
suspend fun getLesson() = withContext(Dispatchers.IO) {
skrape(AsyncFetcher) {
request {
url = "https://google.com"
}
response {
htmlDocument {
relaxed = true
findFirst("body") {
children.drop(1).forEach { row ->
print(row.findAll("xdddddd"))
}
}
}
}
}
}
ok i see, this is related to the following issue:
https://github.com/skrapeit/skrape.it/issues/223 https://github.com/skrapeit/skrape.it/pull/227
will be closed as duplicate
Is your feature request related to a problem? Please describe. Kotlin has nullable types, so it's weird that
findFirst
function throwsElementNotFoundException
instead of returning null. The same applies tofindAll
, why it can't return empty list if none element was found?Describe the solution you'd like Add some function like
findFirstOrNull
and makefindAll
return empty list, when no elements were found.Describe alternatives you've considered Currently, I'm using this as a workaround: