Load document to WebView with JSOUP

前端 未结 2 453
孤街浪徒
孤街浪徒 2021-01-14 13:32

I\'m trying to parse a part of webpage to WebView. I\'m using jsoup library to get part of page that i need, and then load to webview. Here is code:

public          


        
2条回答
  •  攒了一身酷
    2021-01-14 14:09

    I think you are not aware of the fact that

    doc.select("#mp-itn b a")
    

    will return with Elements, i.e. a collection of matching Element nodes, despite your usage of # in the CSS selector, which should indeed only return one Element. If you use

    doc.select("#mp-itn b a").first()
    

    it at least gets the Element with the id you want. Maybe there is more issues to your code though, I did not check for that.

    Addendum

    i am not very familiar with Android development, but the error you are getting points towards a null pointer issue, indicating that element is null where you try to invoke element.html()

提交回复
热议问题