Created
July 14, 2019 21:14
-
-
Save ahmagdy/5357ffa615cc7e9acb5c567236d96857 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
await new BrowserFetcher().DownloadAsync(BrowserFetcher.DefaultRevision); | |
var browser = await Puppeteer.LaunchAsync(new LaunchOptions | |
{ | |
Headless = true | |
}); | |
var page = await browser.NewPageAsync(); | |
await page.GoToAsync("http://natega.thanwya.emis.gov.eg/"); | |
for (int i = 0; i <= 1000; i++) | |
{ | |
var id = (000000+i).ToString(); | |
await page.EvaluateFunctionAsync("() => document.querySelector('input#TextBox1').value = ''"); | |
await page.TypeAsync("input[name='TextBox1']",id ); | |
await page.ClickAsync("#Button3"); | |
await page.WaitForSelectorAsync("#std_name"); | |
var studentName = await page.EvaluateFunctionAsync<string>("() => document.querySelector('#std_name').innerText"); | |
var schoolName = await page.EvaluateFunctionAsync<string>("() => document.querySelector('#school_name').innerText"); | |
var area = await page.EvaluateFunctionAsync<string>("() => document.querySelector('#edara_name').innerText"); | |
Console.WriteLine($"{studentName}, {id}, {schoolName}, {area}"); | |
File.AppendAllText("./th.csv",$"{studentName}, {id}, {schoolName}, {area}\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment