Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
dear sir,
i am really new to java. i want to develop a small programe which gets data from web. i prepared UI for my project but the problem is to get data from web and show in desired fields.


my code:

-------------
public class prices {

protected Shell shlCommodityPriceUpdater;
private Text txtOpen;
private Text txtHigh;
private Text txtLow;
private Text txtYClose;
private Text txtLtp;

/**
* Launch the application.
* @param args
*/
public static void main(String[] args) {
try {
prices window = new prices();
window.open();
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Open the window.
*/
public void open() {
Display display = Display.getDefault();
createContents();
shlCommodityPriceUpdater.open();
shlCommodityPriceUpdater.layout();
while (!shlCommodityPriceUpdater.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}

/**
* Create contents of the window.
*/
protected void createContents() {
shlCommodityPriceUpdater = new Shell();
shlCommodityPriceUpdater.setModified(true);
shlCommodityPriceUpdater.setSize(450, 230);
shlCommodityPriceUpdater.setText("Commodity Price Updater");

Combo selectcommodity = new Combo(shlCommodityPriceUpdater, SWT.NONE);
selectcommodity.setItems(new String[] {"LEAD", "ZINC", "COPPER"});
selectcommodity.setToolTipText("Select a Commodity");
selectcommodity.setVisibleItemCount(3);
selectcommodity.setBounds(21, 10, 132, 23);
selectcommodity.setText("Select a commodity");

txtOpen = new Text(shlCommodityPriceUpdater, SWT.BORDER);
txtOpen.setBounds(25, 101, 76, 21);

txtHigh = new Text(shlCommodityPriceUpdater, SWT.BORDER);
txtHigh.setBounds(124, 101, 76, 21);

txtLow = new Text(shlCommodityPriceUpdater, SWT.BORDER);
txtLow.setBounds(224, 101, 76, 21);

txtYClose = new Text(shlCommodityPriceUpdater, SWT.BORDER);
txtYClose.setBounds(328, 101, 76, 21);

Button btnGetData = new Button(shlCommodityPriceUpdater, SWT.NONE);
btnGetData.setBounds(203, 8, 75, 25);
btnGetData.setText("Get Data");

Label lblOpen = new Label(shlCommodityPriceUpdater, SWT.NONE);
lblOpen.setBounds(25, 78, 55, 15);
lblOpen.setText("OPEN");

Label lblHigh = new Label(shlCommodityPriceUpdater, SWT.NONE);
lblHigh.setBounds(124, 78, 55, 15);
lblHigh.setText("HIGH");

Label lblLow = new Label(shlCommodityPriceUpdater, SWT.NONE);
lblLow.setBounds(223, 78, 55, 15);
lblLow.setText("LOW");

Label lblClose = new Label(shlCommodityPriceUpdater, SWT.NONE);
lblClose.setBounds(328, 78, 55, 15);
lblClose.setText("Y' CLOSE");

txtLtp = new Text(shlCommodityPriceUpdater, SWT.BORDER);
txtLtp.setBounds(178, 161, 76, 21);

Label lblLtp = new Label(shlCommodityPriceUpdater, SWT.NONE);

----------------------------------

i used eclipse for it.

my questions are as follows.

1) when user select a commodity from dropdown window and clicks on the button 'get data'
system need to take the value of commodity as 'stock' and form the link like below.
http://mcxindia.info/stock/
system replaces the valuse of 'stock' with which one it's collected from user defined value. and go to that site and collect the values from the site and places in default places in UI

example: if user select 'LEAD' and clicks the button get data.
then system takes the stock value as 'LEAD' and forms the link like below
" http://mcxindia.info/lead/" then go to this site and collect the values of that stock's OPEN, HIGH, LOW, CLOSE, Last Traded and places in to UI.

so, how can i link my UI to get web data?

thank you.
Posted
Comments
Sergey Alexandrovich Kryukov 29-Aug-14 13:29pm    
Why the tag is "Javascript" is you are talking about Java?
—SA
[no name] 29-Aug-14 15:27pm    
I believe http://www.bing.com/search?q=java+web+scraping is what you are looking for

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900