Use a common user-agent (#5894)
This commit is contained in:
parent
2ad36b1f38
commit
d25f2cc4c3
|
@ -5,7 +5,7 @@ ext {
|
||||||
extName = 'Scantrad'
|
extName = 'Scantrad'
|
||||||
pkgNameSuffix = 'fr.scantrad'
|
pkgNameSuffix = 'fr.scantrad'
|
||||||
extClass = '.Scantrad'
|
extClass = '.Scantrad'
|
||||||
extVersionCode = 15
|
extVersionCode = 16
|
||||||
libVersion = '1.2'
|
libVersion = '1.2'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,8 +21,6 @@ import java.text.SimpleDateFormat
|
||||||
import java.util.Calendar
|
import java.util.Calendar
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlin.math.absoluteValue
|
|
||||||
import kotlin.random.Random
|
|
||||||
|
|
||||||
class Scantrad : ParsedHttpSource() {
|
class Scantrad : ParsedHttpSource() {
|
||||||
|
|
||||||
|
@ -43,7 +41,7 @@ class Scantrad : ParsedHttpSource() {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
override fun headersBuilder(): Headers.Builder = Headers.Builder()
|
||||||
.add("User-Agent", generateRandomUserAgent(Random.nextInt(10, 30).absoluteValue))
|
.add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36")
|
||||||
.add("Accept-Language", "fr")
|
.add("Accept-Language", "fr")
|
||||||
|
|
||||||
// Popular
|
// Popular
|
||||||
|
@ -216,13 +214,4 @@ class Scantrad : ParsedHttpSource() {
|
||||||
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used")
|
override fun imageUrlParse(document: Document) = throw UnsupportedOperationException("Not used")
|
||||||
|
|
||||||
override fun getFilterList() = FilterList()
|
override fun getFilterList() = FilterList()
|
||||||
|
|
||||||
// Misc
|
|
||||||
|
|
||||||
private fun generateRandomUserAgent(length: Int): String {
|
|
||||||
val allowedChars: List<Char> = ('a'..'z') + ('A'..'Z') + ('0'..'9')
|
|
||||||
return (1..length)
|
|
||||||
.map { allowedChars.random() }
|
|
||||||
.joinToString("")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue