Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Java in General
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Java in General
Get data from a website
Prasad Rooge
Greenhorn
Posts: 25
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Im trying to get the table data from a website.
public class TestClass { //public void foo(String url ) throws FileNotFoundException, IOException public static void main(String args[]) throws IOException, InterruptedException { String data=""; File f= new File("C:/Documents and Settings/Designer/Desktop/me/file/new.xls"); FileOutputStream fop = new FileOutputStream(f); Document doc= Jsoup.connect("http://zeenews.india.com/sports/football/euro-cup-2012/points.aspx").get(); for(Element table : doc.select("table")) { //System.out.println("\n"); for(Element row :table.select("tr")) { System.out.println("\n"); fop.write("\n".getBytes()); Elements tds = row.select("td"); for(Element td : tds) { // Thread.sleep(2000); System.out.print(td.text()+"\t"); data=td.text()+"\t"; fop.write(data.getBytes()); } } } fop.flush(); fop.close(); } }
Im getting many copies of tables. how to avoid that?
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
package javax.servlet.annotation does not exist
Writing a sum to a file
upload data and image at the same time
Writing non text file
copy a any type of file
More...