Repository navigation
Expand file tree
/
Copy pathReadTable.txt
More file actions
227 lines (184 loc) · 9.82 KB
/
Copy pathReadTable.txt
File metadata and controls
227 lines (184 loc) · 9.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
package TableData.TableData;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class Finald {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\mohapavi.CORPDOM\\Desktop\\Document\\chromedriver_win32\\chromedriver.exe");
WebDriver driver =new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.way2wealth.com/derivatives/fiiactivity/");
Thread.sleep(5000);
driver.findElement(By.id("ctl00_ContentPlaceHolder1_ctl00_txtstart")).clear();
driver.findElement(By.id("ctl00_ContentPlaceHolder1_ctl00_txtstart")).sendKeys("01/01/2005");
Thread.sleep(5000);
driver.findElement(By.id("ctl00_ContentPlaceHolder1_ctl00_btngo")).click();
Thread.sleep(5000);
WebElement next=driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[19]/td/table/tbody/tr/td[11]/a"));
if(next.isDisplayed())
{
for (int j=2;j<=11;j++)
{
String beforeXpath= "//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[";
String afterXpath_Date="]/td[1]";
String afterXpath_IndexBuy="]/td[3]";
String afterXpath_IndexSell="]/td[4]";
String afterXpath_IndexNet="]/td[5]";
String afterXpath_StockBuy="]/td[7]";
String afterXpath_StockSell="]/td[8]";
String afterXpath_StockNet="]/td[9]";
String afterXpath_IndexOptionBuy="]/td[11]";
String afterXpath_IndexOptionSell="]/td[12]";
String afterXpath_IndexOptionNet="]/td[13]";
String afterXpath_StockOptionBuy="]/td[15]";
String afterXpath_StockOptionSell="]/td[16]";
String afterXpath_StockOptionNet="]/td[17]";
String afterXpath_ContractsNumber="]/td[19]";
String afterXpath_Amount="]/td[20]";
for (int h=1;h<=18;h++)
{
String finalXpath=beforeXpath+h+afterXpath_Date;
String Date=driver.findElement(By.xpath(finalXpath)).getText();
String finalXpath1=beforeXpath+h+afterXpath_IndexBuy;
String IndexBuy=driver.findElement(By.xpath(finalXpath1)).getText();
String finalXpath2=beforeXpath+h+afterXpath_IndexSell;
String IndexSell=driver.findElement(By.xpath(finalXpath2)).getText();
String finalXpath3=beforeXpath+h+afterXpath_IndexNet;
String IndexNet=driver.findElement(By.xpath(finalXpath3)).getText();
String finalXpath4=beforeXpath+h+afterXpath_StockBuy;
String StockBuy=driver.findElement(By.xpath(finalXpath4)).getText();
String finalXpath5=beforeXpath+h+afterXpath_StockSell;
String StockSell=driver.findElement(By.xpath(finalXpath5)).getText();
String finalXpath6=beforeXpath+h+afterXpath_StockNet;
String StockNet=driver.findElement(By.xpath(finalXpath6)).getText();
String finalXpath7=beforeXpath+h+afterXpath_IndexOptionBuy;
String IndexOptionBuy=driver.findElement(By.xpath(finalXpath7)).getText();
String finalXpath8=beforeXpath+h+afterXpath_IndexOptionSell;
String IndexOptionSell=driver.findElement(By.xpath(finalXpath8)).getText();
String finalXpath9=beforeXpath+h+afterXpath_IndexOptionNet;
String IndexOptionNet=driver.findElement(By.xpath(finalXpath9)).getText();
String finalXpath10=beforeXpath+h+afterXpath_StockOptionBuy;
String StockOptionBuy=driver.findElement(By.xpath(finalXpath10)).getText();
String finalXpath11=beforeXpath+h+afterXpath_StockOptionSell;
String StockOptionSell=driver.findElement(By.xpath(finalXpath11)).getText();
String finalXpath12=beforeXpath+h+afterXpath_StockOptionNet;
String StockOptionNet=driver.findElement(By.xpath(finalXpath12)).getText();
String finalXpath13=beforeXpath+h+afterXpath_ContractsNumber;
String ContractsNumber=driver.findElement(By.xpath(finalXpath13)).getText();
String finalXpath14=beforeXpath+h+afterXpath_Amount;
String Amount=driver.findElement(By.xpath(finalXpath14)).getText();
System.out.println(Date+"\t" +IndexBuy+"\t"+IndexSell+"\t"+IndexNet+"\t"+StockBuy+"\t"+StockSell+"\t"+StockNet+"\t"+IndexOptionBuy+"\t"+IndexOptionSell+"\t"+IndexOptionNet+"\t"+StockOptionBuy+"\t"+StockOptionSell+"\t"+StockOptionNet+"\t"+ContractsNumber+"\t"+Amount);
}
Thread.sleep(50000);
if(j==11)
{
WebElement element= driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[19]/td/table/tbody/tr/td[11]/a"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
break;
}
String pageFirstXpath="//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[19]/td/table/tbody/tr/td[";
String pageLastXpath="]/a";
String pageFinalXpath=pageFirstXpath+j+pageLastXpath;
WebElement element= driver.findElement(By.xpath(pageFinalXpath));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
}
}
else
{
System.out.println("One page of data available");
}
Thread.sleep(50000);
for (int k=11;k<=140;k++)
{
WebElement next1=driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[19]/td/table/tbody/tr/td[12]/a"));
if(next1.isDisplayed())
{
for (int j=3;j<=12;j++)
{
String beforeXpath= "//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[";
String afterXpath_Date="]/td[1]";
String afterXpath_IndexBuy="]/td[3]";
String afterXpath_IndexSell="]/td[4]";
String afterXpath_IndexNet="]/td[5]";
String afterXpath_StockBuy="]/td[7]";
String afterXpath_StockSell="]/td[8]";
String afterXpath_StockNet="]/td[9]";
String afterXpath_IndexOptionBuy="]/td[11]";
String afterXpath_IndexOptionSell="]/td[12]";
String afterXpath_IndexOptionNet="]/td[13]";
String afterXpath_StockOptionBuy="]/td[15]";
String afterXpath_StockOptionSell="]/td[16]";
String afterXpath_StockOptionNet="]/td[17]";
String afterXpath_ContractsNumber="]/td[19]";
String afterXpath_Amount="]/td[20]";
for (int h=1;h<=18;h++)
{
String finalXpath=beforeXpath+h+afterXpath_Date;
String Date=driver.findElement(By.xpath(finalXpath)).getText();
String finalXpath1=beforeXpath+h+afterXpath_IndexBuy;
String IndexBuy=driver.findElement(By.xpath(finalXpath1)).getText();
String finalXpath2=beforeXpath+h+afterXpath_IndexSell;
String IndexSell=driver.findElement(By.xpath(finalXpath2)).getText();
String finalXpath3=beforeXpath+h+afterXpath_IndexNet;
String IndexNet=driver.findElement(By.xpath(finalXpath3)).getText();
String finalXpath4=beforeXpath+h+afterXpath_StockBuy;
String StockBuy=driver.findElement(By.xpath(finalXpath4)).getText();
String finalXpath5=beforeXpath+h+afterXpath_StockSell;
String StockSell=driver.findElement(By.xpath(finalXpath5)).getText();
String finalXpath6=beforeXpath+h+afterXpath_StockNet;
String StockNet=driver.findElement(By.xpath(finalXpath6)).getText();
String finalXpath7=beforeXpath+h+afterXpath_IndexOptionBuy;
String IndexOptionBuy=driver.findElement(By.xpath(finalXpath7)).getText();
String finalXpath8=beforeXpath+h+afterXpath_IndexOptionSell;
String IndexOptionSell=driver.findElement(By.xpath(finalXpath8)).getText();
String finalXpath9=beforeXpath+h+afterXpath_IndexOptionNet;
String IndexOptionNet=driver.findElement(By.xpath(finalXpath9)).getText();
String finalXpath10=beforeXpath+h+afterXpath_StockOptionBuy;
String StockOptionBuy=driver.findElement(By.xpath(finalXpath10)).getText();
String finalXpath11=beforeXpath+h+afterXpath_StockOptionSell;
String StockOptionSell=driver.findElement(By.xpath(finalXpath11)).getText();
String finalXpath12=beforeXpath+h+afterXpath_StockOptionNet;
String StockOptionNet=driver.findElement(By.xpath(finalXpath12)).getText();
String finalXpath13=beforeXpath+h+afterXpath_ContractsNumber;
String ContractsNumber=driver.findElement(By.xpath(finalXpath13)).getText();
String finalXpath14=beforeXpath+h+afterXpath_Amount;
String Amount=driver.findElement(By.xpath(finalXpath14)).getText();
System.out.println(Date+"\t" +IndexBuy+"\t"+IndexSell+"\t"+IndexNet+"\t"+StockBuy+"\t"+StockSell+"\t"+StockNet+"\t"+IndexOptionBuy+"\t"+IndexOptionSell+"\t"+IndexOptionNet+"\t"+StockOptionBuy+"\t"+StockOptionSell+"\t"+StockOptionNet+"\t"+ContractsNumber+"\t"+Amount);
}
Thread.sleep(50000);
if(j==12)
{
WebElement next2=driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[19]/td/table/tbody/tr/td[12]/a"));
if(next2.isDisplayed())
{
WebElement element= driver.findElement(By.xpath("//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[19]/td/table/tbody/tr/td[12]/a"));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
}
else
{
System.out.println("All data are write to Excel sheet");
}
}
else
{
String pageFirstXpath="//*[@id='ctl00_ContentPlaceHolder1_ctl00_grdboard']/tbody/tr[19]/td/table/tbody/tr/td[";
String pageLastXpath="]/a";
String pageFinalXpath=pageFirstXpath+j+pageLastXpath;
WebElement element= driver.findElement(By.xpath(pageFinalXpath));
JavascriptExecutor executor = (JavascriptExecutor) driver;
executor.executeScript("arguments[0].click();", element);
}
}
}
else
{
System.out.println("All records are write to excel sheet");
}
}
}
}