Closed MaheshSankaran closed 8 years ago
hi @MaheshSankaran - see the X-TIKA:content
field available in the metadata. That's not HTML, but it's the extracted text.
Unfortunately if you have a look at: http://wiki.apache.org/tika/TikaJAXRS we don't have support in Tika server yet for providing the extracted XHTML. It is supported in tika-app and its -J command for example. See the difference in JSON e.g., X:TIKA-Content in http://wiki.apache.org/tika/GrobidJournalParser.
I've filed an issue at Tika: https://issues.apache.org/jira/browse/TIKA-1716 Feel free to comment there and to help get it implemented. If it's available in Tika-Server we can easily make it available here.
thank you chrismattmann.i have been voted and commented on issue which you created.
thanks @MaheshSankaran you commented your support, thanks. If you have time feel free to contribute a solution too. I likely won't have time to for a bit.
Now that TIKA-1716 is done, I will add support here in the Python library for it. Stand by.
OK, I have this working in a branch:
[chipotle:~] mattmann% python2.7
Python 2.7.8 (default, Sep 27 2014, 11:46:04)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from tika import parser
>>> parser.from_file('/Users/mattmann/.bashrc')
{'content': u'\n\n\n\n\n\n\n\n\nalias tika="java -jar /usr/local/tika/tika-app-1.8.jar"\nalias ls="ls -FHG"\n\n', 'metadata': {u'resourceName': u'.bashrc', u'X-Parsed-By': [u'org.apache.tika.parser.DefaultParser', u'org.apache.tika.parser.txt.TXTParser'], u'Content-Type': u'text/plain; charset=ISO-8859-1', u'X-TIKA:parse_time_millis': u'8', u'Content-Encoding': u'ISO-8859-1'}}
>>> parser.from_file('/Users/mattmann/.bashrc', xmlContent=True)
{'content': u'<html xmlns="http://www.w3.org/1999/xhtml">\n<head>\n<meta name="Content-Encoding" content="ISO-8859-1" />\n<meta name="X-Parsed-By" content="org.apache.tika.parser.DefaultParser" />\n<meta name="X-Parsed-By" content="org.apache.tika.parser.txt.TXTParser" />\n<meta name="Content-Type" content="text/plain; charset=ISO-8859-1" />\n<meta name="resourceName" content=".bashrc" />\n<title></title>\n</head>\n<body><p>alias tika="java -jar /usr/local/tika/tika-app-1.8.jar"\nalias ls="ls -FHG"\n</p>\n</body></html>', 'metadata': {u'resourceName': u'.bashrc', u'X-Parsed-By': [u'org.apache.tika.parser.DefaultParser', u'org.apache.tika.parser.txt.TXTParser'], u'Content-Type': u'text/plain; charset=ISO-8859-1', u'X-TIKA:parse_time_millis': u'6', u'Content-Encoding': u'ISO-8859-1'}}
>>> parser.from_buffer(open('/Users/mattmann/.bashrc', 'r').read())
{'content': u'\n\n\n\n\n\n\n\nalias tika="java -jar /usr/local/tika/tika-app-1.8.jar"\nalias ls="ls -FHG"\n\n', 'metadata': {u'Content-Encoding': u'ISO-8859-1', u'Content-Type': u'text/plain; charset=ISO-8859-1', u'X-TIKA:parse_time_millis': u'5', u'X-Parsed-By': [u'org.apache.tika.parser.DefaultParser', u'org.apache.tika.parser.txt.TXTParser']}}
>>> parser.from_buffer(open('/Users/mattmann/.bashrc', 'r').read(), xmlContent=True)
{'content': u'<html xmlns="http://www.w3.org/1999/xhtml">\n<head>\n<meta name="Content-Encoding" content="ISO-8859-1" />\n<meta name="X-Parsed-By" content="org.apache.tika.parser.DefaultParser" />\n<meta name="X-Parsed-By" content="org.apache.tika.parser.txt.TXTParser" />\n<meta name="Content-Type" content="text/plain; charset=ISO-8859-1" />\n<title></title>\n</head>\n<body><p>alias tika="java -jar /usr/local/tika/tika-app-1.8.jar"\nalias ls="ls -FHG"\n</p>\n</body></html>', 'metadata': {u'Content-Encoding': u'ISO-8859-1', u'Content-Type': u'text/plain; charset=ISO-8859-1', u'X-TIKA:parse_time_millis': u'4', u'X-Parsed-By': [u'org.apache.tika.parser.DefaultParser', u'org.apache.tika.parser.txt.TXTParser']}}
>>>
I'm going to leave it in the branch please try it out @MaheshSankaran branch is html-output65
. Once Tika 1.11 is out, I will go ahead and merge the branch to master.
Great Work @chrismattmann will try once tika 1.11 is release.
Thanks, Mahesh
I stumbled on this it searching for a way around tika-python
because I could not get the XHTML. It seems that you added the xmlContent
flag to the parser interface meanwhile (on 1.15, it works). This is great!
Would you mind adding it to the documentation, or do you still consider it too unstable?
I know apache tika supports HTML output format.But am getting only text format from tika-python. Could you please provide support for HTML output format.
Thanks Mahesh