Results 1 to 2 of 2
Thread: Retrieve Text From A Webpage
- 10-13-2011, 01:00 AM #1
Retrieve Text From A Webpage
Hello, I would like to know how I could retrieve text from a webpage without getting all the code in it. I tried this:
but of course it ends up giving me everything:Java Code:try { url = new URL("http://multibin2.comeze.com/"); BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String str; pan = new JEditorPane(); JScrollPane p = new JScrollPane(pan); add(p); while ((str = in.readLine()) != null) { pan.setText(pan.getText() + "\n" + str); System.out.println(str); } in.close(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { System.out.println(url.getContent()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
What I would like to get out of this is just the "@1@" and the "@nothing new has been added@"<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1138">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times}
</style>
</head>
<body>
<p class="p1">@1@</p>
<p class="p1">@Nothing New Has Been Added@</p>
</body>
</html>
<!-- Free Web Hosting with PHP, MySQL and cPanel, No Ads Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->Last edited by anthropamorphic; 10-13-2011 at 01:02 AM.
- 10-13-2011, 06:27 AM #2
Member
- Join Date
- Jan 2010
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
please help urgent (get text from webpage)
By 3ammary in forum Advanced JavaReplies: 6Last Post: 07-24-2011, 08:29 AM -
Serving up a Webpage
By kammce in forum NetworkingReplies: 7Last Post: 01-01-2011, 02:57 AM -
[HELP] How to run this applet in webpage? [HELP]
By velianko1 in forum Java AppletsReplies: 4Last Post: 12-16-2010, 05:09 PM -
Using regex to retrieve all text inside parentheses
By adhoc334 in forum Advanced JavaReplies: 5Last Post: 08-18-2010, 08:05 PM -
Retrieve values of Text boxes using LIST
By Kayal in forum Web FrameworksReplies: 2Last Post: 03-20-2009, 11:00 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks