@@ -22,13 +22,14 @@ param(
22
22
# $ProgressPreference = "SilentlyContinue"
23
23
24
24
$page = $startpage
25
- $total = 3971
25
+ $total = 4528
26
26
$result = @ ()
27
27
$hasNextPage = $false
28
+ $delay = 3.5
28
29
29
30
# get anonymous sesssion
30
31
Invoke-WebRequest " https://anidb.net" - SessionVariable ' Session' | Out-Null
31
- Start-Sleep - Seconds 2
32
+ Start-Sleep - Seconds $delay
32
33
33
34
function Request-Page ($num )
34
35
{
@@ -37,7 +38,7 @@ function Request-Page($num)
37
38
$url = " https://anidb.net/character/?noalias=1&orderby.name=0.1&page=$num &view=list"
38
39
$response = Invoke-WebRequest $url - WebSession $Session
39
40
# $links = @($response.links | Where-Object { $_.href -match '/character/\d+$' } | Where-Object { $_.outerHTML -match '^<a [^>]+>[^<][^\n]+</a>$' })
40
- Start-Sleep - Seconds 3
41
+ Start-Sleep - Seconds $delay
41
42
return $response.Content
42
43
}
43
44
101
102
Write-Host ' Saving the results...'
102
103
' # https://anidb.net/character' | Out-File - LiteralPath $output
103
104
$result | Sort-Object | Get-Unique | Out-File - LiteralPath $output - Append
104
- Read -Host - Prompt ' Rate limited, plz unban...'
105
- continue
105
+ Write -Host ' Rate limited, plz unban...'
106
+ break
106
107
}
107
108
else
108
109
{
123
124
$pos = $html.IndexOf (' <a href=' , $pos )
124
125
$pos = $html.IndexOf (' >' , $pos )
125
126
$endPos = $html.IndexOf (' </a></td>' , $pos )
126
- $name = $html.Substring ($pos + 1 , $endPos - $pos - 1 ).Replace(' ' , ' ' ).Trim()
127
+ $name = $html.Substring ($pos + 1 , $endPos - $pos - 1 ).Replace(' ' , ' ' ).Replace( ' ` ' , " ' " ). Trim()
127
128
128
129
$pos = $html.IndexOf (' <td data-label="Type"' , $endPos )
129
130
$pos = $html.IndexOf (' >' , $pos )
163
164
$hasNextPage = $false
164
165
}
165
166
} while ($hasNextPage )
166
- Write-Host " Stopped on page $page "
167
+ Write-Host " Stopped on page $page / $total "
167
168
Write-Progress - Activity " Downloading" - Completed
168
169
169
170
Write-Host ' Saving the results...'
0 commit comments