Comments (7)
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.
from tika-python.
thank you chrismattmann.i have been voted and commented on issue which you created.
from tika-python.
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.
from tika-python.
Now that TIKA-1716 is done, I will add support here in the Python library for it. Stand by.
from tika-python.
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.
from tika-python.
Great Work @chrismattmann
will try once tika 1.11 is release.
Thanks,
Mahesh
from tika-python.
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?
from tika-python.
Related Issues (20)
- 'charmap' codec can't decode byte 0x81 in position 279: character maps to <undefined> HOT 2
- Parsed text for EPUB mixes in metadata strings by default, and contains image tags + alt-text if service parameter is set to text HOT 3
- Airgap Environment Setup is unable to start Tika server HOT 6
- Help installing package on macOS M2 Ventura HOT 3
- Can tika extract "Marked Content" (tagged PDFs)? HOT 2
- Hi i am getting the same error HOT 1
- Timeline for tika 2.8 support HOT 3
- Increase retry duration in client only mode HOT 1
- Inclusion of PDF Metadata Title field in Extracted Content HOT 1
- Need to run tika server manualy but previously it works without tika HOT 1
- unable to run tika HOT 1
- Unable to start Tika server HOT 1
- Permission denied HOT 1
- How to fix ReadTimeout: HTTPConnectionPool(host='localhost', port=9998): Read timed out. (read timeout=60) HOT 1
- Can this receive a io[bytes] type? HOT 1
- Tika server 2.9.1 Pdf tesseract Ocr
- SSRF vulnerability: CVE-2022-46364
- Is there any way to preserve temp files?
- Any way to set IOUtils.setByteArrayMaxOverride(VALUE).
- `DeprecationWarning: pkg_resources is deprecated as an API`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tika-python.