forked from windonis/Pull-EksiSozluk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEksi-puller.ps1
77 lines (69 loc) · 1.76 KB
/
Eksi-puller.ps1
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
#Output Class
class Best {
[string]$topic
[string]$yazar
[string]$entry
[string]$fav
}
#creating
$best = [best]::new()
#finder
function Get-Titles
{
param
(
$page
)
$Titles = (Invoke-WebRequest -Uri https://eksisozluk.com/basliklar/m/populer?p=$page).links | ForEach-Object {$_.href} | Where-Object {$_ -match "a=popular"} | ForEach-Object {$_.Substring(0,$_.Length-10)} | ForEach-Object {$_ + '?a=nice'}
return $Titles
}
function Get-PagesCount
{
$count = ((Invoke-WebRequest -Uri https://eksisozluk.com/basliklar/m/populer?p=2).allElements | Where-Object class -eq "pager")."data-pagecount"
return $count
}
function Get-Best
{
param
(
$title
)
$site = "https://eksisozluk.com"
$url = $site + $title
$html = Invoke-WebRequest -Uri $url
#class filler
$best.topic = $url
$best.entry = ($html.allelements | Where-Object "data-id")."outerText"[1]
$best.yazar = ($html.allelements | Where-Object "data-id")."data-author"[1]
$best.fav = ($html.allelements | Where-Object "data-id")."data-favorite-count"[1]
#output
$best | Format-List
$input = read-host "Please any key to Continue"
switch ($input) {
Default {
Clear-Host
$best | Format-List
}
}
}
function Start-Puller
{
$counts = Get-PagesCount
for ($i = 1; $i -le $counts; $i++)
{
$titles = Get-Titles
foreach ($title in $titles)
{
Write-Host $title -BackgroundColor red -ForegroundColor White
Write-Host "
### ###
## ##
# #
#
"
Get-Best -title $title
}
}
}
#run the script
Start-Puller