I would like to open a URL and extract tables from the HTML code of the web

Hi I have opened a URL say www.amazon.com and I would like to extract te tables in that particular web page would somebody out there help me with the code so that the output file displays only the relevant tables containing books and its prices dropping out all other data on the web page . My code for opening the URL goes here. Any quick help would be appreciated
import java.net.*;
import java.io.*;
class ConnectionTest {
public static void main(String[] args) {
try {
URL amazon = new URL("http://www.amazon.com");
URLConnection amazonConnection = amazon.openConnection();
DataInputStream dis = new DataInputStream(amazonConnection.getInputStream());
String inputLine;
while ((inputLine = dis.readLine()) != null) {
System.out.println(inputLine);
dis.close();
} catch (MalformedURLException me) {
System.out.println("MalformedURLException: " + me);
} catch (IOException ioe) {
System.out.println("IOException: " + ioe);
}

The quick and dirty way ( Not perfect and will be prone to errors ) :
As you read the lines using readLine(), look for the string "<table>" (Perhaps using String.indexOf ? -- Java API for class String -- http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html)
If the start tag is found, start dumping lines into a String (string concatenation), keep doing it until you find the end tag, using the method mentioned.
Also, you may want to consider the case where <table> or </table> may not be at the beginning of the line, so you may want to use String.substring to selectively extract part of the line that you want to keep.
Oh, and don't assume that the <table> tag is in lower case, and don't forget that there may be other attributes that are defined in the start and end tags.
I wouldn't recommend using this method other than a quick and dirty extraction. If you really want to do things the right way, use a HTML parser or use the Amazon Web Services as paulcw suggested.
Amazon Web Services:
http://aws.amazon.com

Similar Messages

  • I would like to transfer my iTunes and photos etc from my PC to my new iMac via a external hard drive. Would somebody recommend one. I read that the Western Digital Mybook Essential 3.0 is good.

    I would like to transfer my iTunes and photos etc from my PC to my new iMac via a external hard drive. Would somebody recommend one. I read that the Western Digital Mybook Essential 3.0 is good. Though as Mac has 2.0 is this fast enough? I am a basic user, surfing only.

    If you plan on using the WD with the Mac after the iTunes transfer I would strongly recommend against WD. WD external HD's tend to be the most troublesome with Macs. If you intend to use the drive for backup using Time Machine or creating a bootable clone then I'd recommend a higher quality drive than WD. The drives I'd recommend in that case would be:
    OWC Mercury Elite Pro series
    LaCie d2 Quadra series
    G-Tech G-DRIVE series
    These are all high quality drives and enclosures with similar features. Personally I use the LaCie's however I would be happy to have OWC and G-Tech on my desk too. FWIW I've been using the LaCie's for 4 years and have 4 of them, all work perfectly and have never given me any trouble.
    You also my find this article helpful: Move an iTunes library from a PC to Mac (and back)

  • I would like to transfer a playlist and associated music from one computer on a home sharing network to another without transferring the entire library.  How?

    I would like to transfer a playlist and associated music from one computer to another in a home sharing network without transfering the entire itunes library.  How would I do that?

    you can transfer playlists using home sharing but it won't copy the actual music files within to the other machine.
    however, i believe TuneRanger can do that.

  • I would like to make one file and add several related files of photos in the one event.  Keeping photos in seperate event files in one large event file.  Is this possible?

    I would like to make one event file and add several realted event files in this one event file without putting all photos together.  Can this be done?

    Files and events ahve nothing to do with each other
    If you are looking for "sub-events" that is not a feature of iPhoto
    you can use albums and folders - albums hold photos and folders hold albums or other folders
    If thsi does not answer your queation please ask it again - it is not clear
    LN

  • I would like to open a Firefox browser with multiple tabs per topic, like work1/work2/hobby and see that given name in the taskbar, instead of the tab-name

    I usually open a new browser window per subject, let's say I'm shopping online for something and open about 5 tabs for that, but in the same time I am working on 2 systems which are lookalike, but defenitely should not be mixed average 6 tabs open per subject. Also I read something on my hobby and I open another window and want to read a few tabs on that.
    I don't want them to mix and preferably I'd like to see a self-chosen subject for a minimized window in the taskbar.
    Is there a feature like this or is it possible to add a feature like this?

    Another alternative by the way maybe to use multiple Firefox profiles. I will give more information on that if required. It is fairly easy if you are used to using computers but not something this forum officially supports with KB articles.
    The bult in Tabs groups sounds more like what you want. Did you try that ?
    As for trying to interest Developers. You could make a comment using ''feedback'' but I would not hold out much hope unless you yourself know a developer willing to undertake the coding and press for its use. Maybe you would be more likely to interest and get something from add-on developers, assuming a similar add-on does not already exist.
    The people who answer questions here, for the most part, are other Firefox users volunteering their time (like me), not Mozilla employees or Firefox developers.
    If you want to leave feedback for Firefox developers, you can go to the Firefox ''Help'' menu and select ''Submit Feedback...'' or use [https://input.mozilla.org/feedback this link]. (You'll need to be on the latest version of Firefox to submit feedback). Your feedback gets collected at http://input.mozilla.org/, where a team of people read it and gather data about the most common issues.

  • I would like to open a second iTunes account in another country, but still maintain my original Canadian account.  I have read the advice regarding signing out of the original account,and then signing in and setting up a new account.  but will I still be

    I would like t open a second iTunes account for a different country, but still be able to access my original account. It was not clear inthe documentation I read on this subject if this was indeed possible - using the signing out/in, create new account procedure.

    How recently did you switch?  If it's less than 60 days, then Verizon simply reinstates your previous account.  The fact that you were on the EDGE plan and mailed the devices back, and they apparently are somewhere in the system, could cause complications, and it might just work out that you just go back on the same plan and they set you up with the same devices.  I'm not sure how it will go - but since you are still being billed for the devices... 

  • I would like to create a pop-up window appear from Labview Interface. In this window, I will have a slide control and an image taken from a camera. The main VI have to run while pop-up window is open. How can I do ?

    When I pushed a button, this pop-up window has to appear. There will be a slide control and a picture from a camera in this window. Is it possible to make appear this windows while main VI Interface continue to run ? How can I do this ? Thank you for your answers.
    Cyril.

    Here you go. This is simple example. Maybe not the best way, I am just
    beginner in LV and still not comfortable with data flow that much. I prefer
    events, so I would change this to use Event Structures.
    When you click on OK button on SliderMain, it opens Slider.vi. Now both
    windows are open and you can interact with both. Now if you click on OK
    again with Slider.vi open, you run into problems. Only thing I did was
    change VI properties of slider.vi, mainly window appearance.
    vishi
    "Cy" wrote in message
    news:[email protected]..
    > I would like to create a pop-up window appear from Labview Interface.
    > In this window, I will have a slide control and an image taken from a
    > camera. The main VI hav
    e to run while pop-up window is open. How can I
    > do ?
    >
    > When I pushed a button, this pop-up window has to appear. There will
    > be a slide control and a picture from a camera in this window. Is it
    > possible to make appear this windows while main VI Interface continue
    > to run ? How can I do this ? Thank you for your answers.
    > Cyril.
    [Attachment SliderMain.vi, see below]
    [Attachment Slider.vi, see below]
    Attachments:
    SliderMain.vi ‏16 KB
    Slider.vi ‏11 KB

  • I have 2 displays 1920 and 3840, use 1920 for every day work, some pages I would like to open in 3840 display, is this possible?

    I have 2 displays 1920x1080 and 3840x2160,
    I use 1920x1080 for every day work, some pages I would like to open in or redirect to the 3840x2160 display, is this possible?

    No, but there is a developer tool that you can add a custom size to. It is called Responsive Design View.

  • When I point and click on any link I get a drop down window asking if I would like to open in new window etc.   How can I turn it off ?

    When I point and click on any link I get a drop down window asking if I would like to open in new window etc.   How can I turn it off ?

    Thank you the-edmeister.
    I downloaded the menu editor extension but I can't open it.
    Searching on the web for something to open it I get the message from the windows website:
    File Type: Unknown
    Description: Windows does not recognize this file type.
    Any suggestions?
    Thanks Steve Shmurak

  • I have a MackBook A1181 I need to upgrade my Safari so Outlook will work and would like to get some kind of word/writing tool on it... the info is:  Model Name:     MacBook   Model Identifier:     MacBook1,1   Processor Name:     Intel Core Duo   Processo

    I have a MackBook A1181 that I bought off Ebay :/ it came with pirate discs and no info....I need to upgrade my Safari so Outlook will work and would like to
    get some kind of word/writing tool on it... the info is:
    Model Name:          MacBook
      Model Identifier:          MacBook1,1
      Processor Name:          Intel Core Duo
      Processor Speed:          1.83 GHz
      Number Of Processors:          1
      Total Number Of Cores:          2
      L2 Cache (per processor):          2 MB
      Memory:          2 GB
      Bus Speed:          667 MHz
      Boot ROM Version:          MB11.0061.B03
      SMC Version:          1.4f12
      Serial Number:          4H631CVDU9B
      Sudden Motion Sensor:
      State:          Enabled
    Can anybody help?!

    First correct the pirate disc issue. Buy OS X 10.6 Snow Leopard from Apple for $19.99 here http://store.apple.com/us/product/MC573/mac-os-x-106-snow-leopard
    Snow Leopard is the latest version your macbook 1,1 will run. Oitlook is part of the Microsoft Office suite, if you want outlook you'll need to also purchase Office. If you can get by with Apple's mail program there are free alternatives to Office like Libre Office or Open Office.

  • I would like to uninstall firefox 4 and then reinstall it, but how do I save my book marks?

    I would like to uninstall firefox 4 and then reinstall it, but I don't want to lose all of my bookmarks. The actual problem is a persona that won't stay changed. We change it, but every time we close Firefox it goes back to the Persona we changed it from when we start up Firefox again. I was just planning on uninstalling and reinstalling Firefox, but, like I said, I don't want to lose my bookmarks. How do I save my bookmarks in Firefox 4?

    You could always remove/disable the Persona that you don't want. Go to Add-ons > Appearance, and then just disable/remove the offending Persona.
    Though, if you really want to save your bookmarks:
    Bookmarks > Show All Bookmarks > Which will open the Library > Look for Import and Backup > Backup...> and it will prompt to you save the file somewhere. To add them back into Firefox, go back to the library > Import and Backup again > Restore > Choose File... > and then open the file you saved earlier.

  • HT4759 I have an iMac, iMac, 10,1 10.8. I would like to have iCloud downloaded to my computer.  Does my computer have the system requirement necessary. I use iCal on my Apple Notebook and Iphone 4S. Thank you!

    I have an iMac, iMac, 10,1 10.8. I would like to have iCloud downloaded to my computer.  Does my computer have the system requirement necessary. I use iCal on my Apple Notebook and Iphone 4S and want it to my Mac Desktop to sinc with all my Apple Products. Thank you!

    The minimum requirement for iCloud is Lion 10.7.5 (Mavericks preferred): the iCloud Preference Pane does not appear on earlier systems - the MobileMe pane appears on Lion and earlier but is now non-functional - you cannot now open or access a MobileMe account.
    To make use of iCloud you will have to upgrade your Mac to Lion or Mavericks, provided it meets the requirements.
    The requirements for Lion are:
    Mac computer with an Intel Core 2 Duo, Core i3, Core i5, Core i7, or Xeon processor
    2GB of memory
    OS X v10.6.6 or later (v10.6.8 recommended)
    7GB of available space
    Lion is available in the Online Apple Store ($19.99). Mountain Lion (10.8.x) is also available there at the same price (though it's reported to have been removed from sale in some countries so may well cease to be available generally) but there seems little point as the system requirements are the same for Mavericks (10.9.x) - which is free - unless you need to run specific software which will run on Mountain Lion only.
    The requirements for Mountain Lion and Mavericks are:
    OS X v10.6.8 or later
    2GB of memory
    8GB of available space
      and the supported models are:
    iMac (Mid 2007 or newer)
    MacBook (Late 2008 Aluminum, or Early 2009 or newer)
    MacBook Pro (Mid/Late 2007 or newer)
    Xserve (Early 2009)
    MacBook Air (Late 2008 or newer)
    Mac mini (Early 2009 or newer)
    Mac Pro (Early 2008 or newer)
    It is available from the Mac App Store (in Applications).
      You should be aware that PPC programs (such as AppleWorks) will not run on Lion or above; and some other applications may not be compatible - there is a useful compatibility checklist at http://roaringapps.com/apps:table

  • OSX: I would like DW opens on the 2nd screen

    I use DW CS5 on a MacBook Pro with a 2nd monitor connected.
    I would like DW opens on the 2nd screen (because it's much bigger) and so used the MacBook screen for my browser tests.
    But I can not find the way to move DW to 2nd screen.
    Am I really stupid or not ?
    Thank you
    Marco

    pifouxx wrote:
    Am I really stupid or not ?
    Not really.  You are thinking like Einstein was thinking when he wanted  his kitten to go in the small hole he drilled specifically while the kitten's mum had her own big hole.  To his surprise both went through the same big hole and he said what a waste of time drilling the small hole!!!!
    You haven't said how you have connected the two monitors.  Are you using some switches like KVM switches that can do the job most efficiently? <http://www.kvms.com/Product/GCS78.aspx>
    There must be some cheap ones in your area so just shop around.
    Alternatively, Just connect one monitor (big one) to your machine which you work on and to view your pages you will need to upload the files somewhere so that your other machine can connect to them using the browser like any other websites.  You need two machines to do this, of course!

  • I have a Canon Vixia HV30 and would like to know if I can transfer video from it to a new MacBook Pro? The camcorder has a HDV/DV output. Is that compatible with firewire?

    I have a Canon Vixia HV30 and would like to know if I can transfer video from it to a new MacBook Pro? The camcorder has a HDV/DV output. Is that compatible with firewire?

    Hi Codye24
    I don't know if you saw this thread
    Connecting a Canon HV30 camcorder vai a thunderbolt port to a new imac
    Hope that this helps
    Kevin

  • How to open an URL and close the URL window, using adobe javascript

    Hi,
      Is it possible to open an URL and close the URL back again(without allowing the user to perform any other operation)? I was able to acheive the opening of the URL, using the app.launchURL("address". true); - But here it lauches in new window, and how do i close the window using the javascript. Is it possible?
    Thanks.

    Hi all
    In addition to what Bobby W - Adobe TS added, you might find
    the following useful as a bypass or workaround to the pesky prompt.
    var pw=window.parent;pw.opener=window.self;window.open("
    http://www.adobe.com");
    pw.close();
    I think this will only work for IE browsers. Actually, I
    think the whole window.close() only works for IE, but could be
    wrong about that.
    Cheers... Rick

Maybe you are looking for