Skip to content

Instantly share code, notes, and snippets.

@jtmuller5
Created March 6, 2020 16:59
Show Gist options
  • Save jtmuller5/69368e24f5139b5637fb8cff3c701fcf to your computer and use it in GitHub Desktop.
Save jtmuller5/69368e24f5139b5637fb8cff3c701fcf to your computer and use it in GitHub Desktop.
class SearchNews(var main: MainActivity) : AsyncTask<String, Void, String>() {
override fun doInBackground(vararg params: String): String {
var searchString = params.get(0)
val url = "https://news.google.com/rss/search?q=$searchString&hl=en-US&gl=US&ceid=US:en"
var parseDoc = Jsoup.connect(url).parser(Parser.xmlParser()).get() //can also use maxBodySize(0) and timeout(0)
var items : Elements? = parseDoc?.select("item")
Log.d("result",items.toString())
return "Added"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment