-2

I want to get/parse Information from these websites(Freebase/Wikipedia...) in JSON format in Android.My aim is to post variable like "Obama" and get information about him in JSON.I searched for it but just found some things for XML (APIs). I allready programmed my JSON Parser but I need the source ^^

Are there any ways to get it easily ? It doesn't have to be Wikipedia or Freebase IF there are other alternatives. I only know these websites to get Info.

Thanks for everyone !

2 Answers2

0

One way i can think of is first get the HTML content

    URL yahoo = new URL(url);
    URLConnection yc = yahoo.openConnection();
    BufferedReader in = new BufferedReader(new InputStreamReader(
            yc.getInputStream(), "UTF-8"));
    String inputLine;
    StringBuilder a = new StringBuilder();
    while ((inputLine = in.readLine()) != null)
        a.append(inputLine);
    in.close();

Then convert the HTML to json using Get data from HTML and convert it to JSON

Community
  • 1
  • 1
M Sach
  • 33,416
  • 76
  • 221
  • 314
0

First you can convert HTML to XML Then use framework like Jackson json parser like XML to JSON.

ObjectMapper xmlMapper = new XmlMapper();
String xml = xmlMapper.writeValueAsString(new Simple());
xmlMapper.writeValue(new File("/tmp/stuff.json"), new Simple());

Samples :https://github.com/FasterXML/jackson-dataformat-xml