I have written code to parse Rss, but I have problem with auto redirect to mobile site For Example : my URL is http://danviet.vn/rss/24/thoi-su.rss, but when i parse this URL, i got the error : file not found : http://m.danviet.vn/rss/24/thoi-su.rss
My code for parsing:
try {
URL url = new URL(link);
System.out.println(url.getHost());
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser parser = factory.newSAXParser();
XMLReader reader = parser.getXMLReader();
RSSHandler handler = new RSSHandler();
reader.setContentHandler(handler);
InputSource source = new InputSource(url.openStream());
reader.parse(source);
return handler.getItemList();
} catch (MalformedURLException e) {
e.printStackTrace();
}