Last active
March 10, 2020 14:50
-
-
Save latant/69e5dc951db69b78577cfb700945ab90 to your computer and use it in GitHub Desktop.
'Download your facebook information' generates html to view your messages, but the href attributes contain wrong directory names.It can be solved quickly by 'lowerCase-ing' the href attributes that start with 'messages' path segment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.jsoup.Jsoup | |
import java.io.File | |
fun main(args: Array<String>) { | |
val (srcFile, targetFile) = args | |
val doc = Jsoup.parse(File(srcFile).readText()) | |
doc.select("[href]").toList().forEach { | |
val pathSegments = it.attr("href").split("/").toMutableList() | |
if (pathSegments[0] == "messages") { | |
pathSegments[2] = pathSegments[2].toLowerCase() | |
it.attr("href", pathSegments.joinToString("/")) | |
} | |
} | |
File(targetFile).writeText(doc.toString()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment