Jsoup.connect()
メソッドを使用してWebサイトから取得したHTMLソースがあります。そのHTMLソースからのコードの一部を以下に示します(リンク:https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community)はJsoup H2タグの前にすべてを削除
.....
<p>When you set dependencies in your VSIX manifest, you must specify Component IDs
only. Use the tables on this page to determine our minimum component dependencies.
In some scenarios, this might mean that you specify only one component from a workload.
In other scenarios, it might mean that you specify multiple components from a single
workload or multiple components from multiple workloads. For more information, see
the
<a href="../extensibility/how-to-migrate-extensibility-projects-to-visual-studio-2017" data-linktype="relative-path">How to: Migrate Extensibility Projects to Visual Studio 2017</a> page.</p>
.....
<h2 id="visual-studio-core-editor-included-with-visual-studio-community-2017">Visual Studio core editor (included with Visual Studio Community 2017)</h2>
.....
<h2 id="see-also">See also</h2>
.....
私はjsoup
を使ってやりたいことは、私は<h2 id="visual-studio-core-editor-included-with-visual-studio-community-2017">Visual Studio core editor (included with Visual Studio Community 2017)</h2>
、およびすべての前にすべての単一のHTML部分を削除したい、ということです
try {
document = Jsoup.connect(Constants.URL).get();
}
catch (IOException iex) {
iex.printStackTrace();
}
document = Parser.parse(document.toString().replaceAll(".*?<a href=\"workload-and-component-ids\" data-linktype=\"relative-path\">Visual Studio 2017 Workload and Component IDs</a> page.</p>", "") , Constants.URL);
document = Parser.parse(document.toString().replaceAll("<h2 id=\"see-also\">See also</h2>?.*", "") , Constants.URL);
return null;
:
<h2 id="see-also">See also</h2>
(を含む)の後、私は私のためにこのようなソリューションが、これはかなりのdidntの仕事を持っています
助けていただければ幸いです。
これについて詳しく説明できますか?なぜあなたは、特定のクラスやタグを選択して削除しないのですか?そうでなければ、あなたが望む特定のタグだけを選ぶことができます。 – soorapadman
私が受け取るhtmlページは複雑な構造をしています。それは他のタグの間にたくさんのタグが詰め込まれています。あなたは自分で確認することができます。ページsrcはhttps://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-communityです。 私は、Visual Studioコアエディタ(Visual Studio Community 2017に含まれています)[1]と[Unaffiliated components] [2]の間でHTMLソースをスクラップすることを試みています。 しかし、私は[1]と[2]の表の後に何かを置き換える方法を得ることができません。また、サイトをチェックしてください – Sparker0i
また、私はJSOUPを使ってこれをやりたいと思っていました。ウェブサイトからHTMLを解析しているので、それは一定のファイルではありません(あなたが言っているように) – Sparker0i