1
を使用してフォーマットされたテキストとしてstdoutにレンダリング、私はブラウザw3mのまたはオオヤマネコのようなコマンドラインで HTMLをレンダリングの問題につまずきました。CLI Googleのカードビューアを構築しながらHTMLをRubyの
Nokogiri::HTML::parse(card_snippet).text
をしかし、次のようにそれが出て印刷します:私はテキストを使用している来ている最も近い鋸山から吐き出す
"Albert EinsteinTheoretical PhysicistAlbert Einstein was a German-born theoretical physicist. He developed the general theory of relativity, one of the two pillars of modern physics. Einstein's work is also known for its influence on the philosophy of science. WikipediaBorn: March 14, 1879, Ulm, GermanyDied: April 18, 1955, Princeton, New Jersey, United StatesInfluenced: Satyendra Nath Bose, Wolfgang Pauli, Leo Szilard, moreInfluenced by: Isaac Newton, Mahatma Gandhi, moreBooksThe World as I See It1949Relativity: The Special a...1916Ideas and Opinions2000Out of My Later Years2006The Meaning of Relativity1922The Evolution of Physics1938People also search forIsaac NewtonEduard EinsteinSonStephen HawkingElsa EinsteinSpouseMileva MarićFormer spouseThomas Edison"
しかし、使用してオオヤマネコ:
cat card_snippet.html | lyx -dump -stdin
Albert Einstein
Theoretical Physicist
Albert Einstein was a German-born theoretical physicist. He
developed the general theory of relativity, one of the two pillars
of modern physics. Einstein's work is also known for its influence
on the philosophy of science. Wikipedia
Born: March 14, 1879, Ulm, Germany
Died: April 18, 1955, Princeton, New Jersey, United States
Influenced: Satyendra Nath Bose, Wolfgang Pauli, Leo
Szilard,
注:ノイズを除去した後。しかし、それにもかかわらず、行末は適切です。
Rubyで同様のソリューションをお考えですか? htmlスニペット:Pastebin Link。文言として
あなたの質問は良いフィットではありません。あなたは基本的に何かを推薦するか、何かを書く方法について私たちの意見を述べることを求めていますが、それはチュートリアルになります。代わりに、あなたが何をしたいのかを特定し、それを書いてみることになっているので、問題に遭遇したときにその問題に関する特定の質問をしてください。 「[mcve]」もお読みください。データ(HTML)は、問題を実証するのに必要な最小限のものを使用して、質問自体に含める必要があります。リンクが壊れてしまって、意味をなさない質問が出る。 –
あなたが見ている問題はNodeSetで 'text'を使うことによるものです。すべての要素を繰り返し処理し、テキストを個別に抽出する必要があります。 –
rubyでシステムckmmandを実行してw3mの出力をキャプチャすることはできますか? –