Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Test()
- Dim bot As New Selenium.WebDriver, lastPage As Integer
- With bot
- .Start "chrome", "http://student.moe.gov.eg/new/index.aspx"
- .get "http://student.moe.gov.eg/new/index.aspx"
- .FindElementById("ctl00_ContentPlaceHolder1_TextBox1").SendKeys "3303364"
- .FindElementById("ctl00_ContentPlaceHolder1_TextBox2").SendKeys "33005431"
- .FindElementById("ctl00_ContentPlaceHolder1_TextBox3").SendKeys "mypassword"
- .FindElementById("ctl00_ContentPlaceHolder1_Button2").Click
- .FindElementById("ctl00_ContentPlaceHolder1_LinkButton4").Click
- .Wait 3000
- lastPage = Val(Split(.FindElementByXPath("//div[@class='crtoolbar']//span[contains(.,'/')]").Text, " / ")(1))
- 'Debug.Print lastPage
- Dim ws As Worksheet, cnt As Long, i As Long, j As Long, n As Long
- Dim tables As Object
- Dim headers(), mappings(), arr(13), newarr(13)
- cnt = 1
- Set ws = ThisWorkbook.Worksheets("Sheet1")
- Set tables = .FindElementsByCss("table[width='100%'] table:first-child")
- '================================
- headers = Array("م", "كود الطالب", "الرقم القومي", "اسم الطالب", "الجنسية", "الديانة", "تاريخ الميلاد", "يوم", "شهر", "سنة", "محافظة الميلاد", "حالة القيد", "النوع", "ملاحظات")
- mappings = Array(3, 8, 9, 12, 11, 10, 2, 7, 1, 6, 5, 4, 13)
- ws.Cells(1, 1).Resize(1, UBound(headers) + 1) = headers
- For i = 90 To 504 Step 26
- arr(0) = vbNullString
- For j = 0 To 12
- arr(mappings(j)) = Application.Trim(tables.Item(i + (2 * (j))).Text)
- Next j
- ' For j = UBound(arr) To LBound(arr) Step -1
- ' newarr(n) = arr(j)
- ' ' If n = 12 Then
- ' ' newarr(n) = CDate(Day(newarr(n)) & "/" & Month(newarr(n)) & "/" & Year(newarr(n)))
- ' ' End If
- ' n = n + 1
- ' Next j
- ws.Cells(cnt + 1, 1).Resize(1, UBound(arr) + 1) = arr
- cnt = cnt + 1: n = 0
- Next i
- '================================
- ' Dim tbl As Selenium.TableElement
- '
- ' Set tbl = .FindElementById("Table1").AsTable
- '
- ' 'Print To Excel
- ' tbl.ToExcel ThisWorkbook.Sheets("Sheet1").Range("A1")
- Stop
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement