完成数据清洗

This commit is contained in:
zhushenwudi 2025-01-14 23:16:21 +08:00
parent da848c9128
commit a070f82853
4 changed files with 73 additions and 48 deletions

View File

@ -15,7 +15,7 @@ dependencies {
implementation('org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1')
implementation 'org.jsoup:jsoup:1.18.3'
implementation "org.ktorm:ktorm-core:4.1.1"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1'
implementation("mysql:mysql-connector-java:8.0.33")
}

View File

@ -24,20 +24,21 @@ suspend fun main(args: Array<String>) {
val database = Database.connect(
url = "jdbc:mysql://localhost:3306/sif_card",
driver = "com.mysql.jdbc.Driver",
driver = "com.mysql.cj.jdbc.Driver",
user = "root",
password = ""
)
cardList.forEach { card ->
database.useTransaction {
val count = database
.from(TCard)
.select()
.where { TCard.name eq card.name }
.totalRecordsInAllPages
if (count > 0) {
return@forEach
var id = -1
for (row in database.from(TCard).select().where { TCard.name eq card.name }) {
row[TCard.characterName]?.let { characterName ->
if (characterName.isNotEmpty()) {
return@forEach
}
id = row[TCard.id]!!
}
}
gameList.find { gameCh -> gameCh.name.contains(card.name) }?.let { gameCh ->
@ -89,29 +90,53 @@ suspend fun main(args: Array<String>) {
tables[4].select(".mu__table--row2").apply {
card.specialSkillInfo = select(".mu__table--col1").text()
}
}
} ?: run { return@forEach }
println(card)
database.insert(TCard) {
set(it.name, card.name)
set(it.characterId, card.characterId)
set(it.characterName, card.characterName)
set(it.type, card.type)
set(it.rarity, card.rarity)
set(it.maxLevel, card.maxLevel)
set(it.maxHp, card.maxHp)
set(it.smile, card.smile)
set(it.pure, card.pure)
set(it.cool, card.cool)
set(it.illustId, card.illustId)
set(it.evolveIllustId, card.evolveIllustId)
set(it.group, card.group)
set(it.team, card.team)
set(it.date, card.date)
set(it.centerSkillName, card.centerSkillName)
set(it.centerSkillInfo, card.centerSkillInfo)
set(it.specialSkillName, card.specialSkillName)
set(it.specialSkillInfo, card.specialSkillInfo)
if (id == -1) {
database.insert(TCard) {
set(it.name, card.name)
set(it.characterId, card.characterId)
set(it.characterName, card.characterName)
set(it.type, card.type)
set(it.rarity, card.rarity)
set(it.maxLevel, card.maxLevel)
set(it.maxHp, card.maxHp)
set(it.smile, card.smile)
set(it.pure, card.pure)
set(it.cool, card.cool)
set(it.illustId, card.illustId)
set(it.evolveIllustId, card.evolveIllustId)
set(it.group, card.group)
set(it.team, card.team)
set(it.date, card.date)
set(it.centerSkillName, card.centerSkillName)
set(it.centerSkillInfo, card.centerSkillInfo)
set(it.specialSkillName, card.specialSkillName)
set(it.specialSkillInfo, card.specialSkillInfo)
}
} else {
database.update(TCard) {
set(it.characterName, card.characterName)
set(it.type, card.type)
set(it.rarity, card.rarity)
set(it.maxLevel, card.maxLevel)
set(it.maxHp, card.maxHp)
set(it.smile, card.smile)
set(it.pure, card.pure)
set(it.cool, card.cool)
set(it.illustId, card.illustId)
set(it.evolveIllustId, card.evolveIllustId)
set(it.group, card.group)
set(it.team, card.team)
set(it.date, card.date)
set(it.centerSkillName, card.centerSkillName)
set(it.centerSkillInfo, card.centerSkillInfo)
set(it.specialSkillName, card.specialSkillName)
set(it.specialSkillInfo, card.specialSkillInfo)
where { TCard.id eq id }
}
}
}

View File

@ -457,7 +457,7 @@
{
"id": 10050010,
"characterId": 1005,
"name": "μ'の元気印",
"name": "μ'sの元気印",
"illustId": "01005_0010_00",
"evolveIllustId": "01005_0010_01"
},

View File

@ -1,7 +1,7 @@
[
{
"url": "https://gamerch.com/lovelivesif2/767609",
"name": "Aquoursと申しますわ黒澤ダイヤ",
"name": "Aqoursと申しますわ黒澤ダイヤ",
"rarity": 2
},
{
@ -31,17 +31,17 @@
},
{
"url": "https://gamerch.com/lovelivesif2/758859",
"name": "μ’sと私矢澤にこ",
"name": "µ'sと私矢澤にこ",
"rarity": 1
},
{
"url": "https://gamerch.com/lovelivesif2/811888",
"name": "μ’sのクリスマス園田海未",
"name": "µ'sのクリスマス園田海未",
"rarity": 1
},
{
"url": "https://gamerch.com/lovelivesif2/748012",
"name": "μ’sへの想い小泉花陽",
"name": "µ'sへの想い小泉花陽",
"rarity": 1
},
{
@ -121,7 +121,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/748007",
"name": "[いらっしゃませ♪]南ことり",
"name": "[いらっしゃませ♪]南ことり",
"rarity": 1
},
{
@ -781,7 +781,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/767340",
"name": "[サプライズBBQ]宮下愛",
"name": "[サプライズ]宮下愛",
"rarity": 1
},
{
@ -1536,7 +1536,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/815232",
"name": "も方便]鬼塚夏美",
"name": "も方便]鬼塚夏美",
"rarity": 1
},
{
@ -1551,7 +1551,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/748053",
"name": "[地上230メートル]桜小路きな子",
"name": "[地上メートル]桜小路きな子",
"rarity": 1
},
{
@ -1691,7 +1691,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/767462",
"name": "[好きなった内浦]桜内梨子",
"name": "[好きなった内浦]桜内梨子",
"rarity": 3
},
{
@ -1801,7 +1801,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/767420",
"name": "いを馳せて]高海千歌",
"name": "いを馳せて]高海千歌",
"rarity": 3
},
{
@ -2081,7 +2081,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/767417",
"name": "[水泳日和]高海千歌",
"name": "[水泳日和]高海千歌",
"rarity": 3
},
{
@ -2116,7 +2116,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/818426",
"name": "[海眺める初日の出]高海千歌",
"name": "[海眺める初日の出]高海千歌",
"rarity": 1
},
{
@ -2391,7 +2391,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/815221",
"name": "[笑う門には福来る]嵐千砂都",
"name": "[笑う門には福来る]嵐千砂都",
"rarity": 1
},
{
@ -2416,7 +2416,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/766205",
"name": "[紅のかざぐるま]優木せつ菜",
"name": "[紅のかざぐるま]優木せつ菜",
"rarity": 2
},
{
@ -2601,7 +2601,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/823803",
"name": "[試食挑戦者募集]若菜四季",
"name": "[試食挑戦者募集]若菜四季",
"rarity": 2
},
{
@ -2636,7 +2636,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/813588",
"name": "やかな街!]高海千歌",
"name": "にぎやかな街!]高海千歌",
"rarity": 2
},
{
@ -2746,7 +2746,7 @@
},
{
"url": "https://gamerch.com/lovelivesif2/759114",
"name": "[間違えないで!]南ことり",
"name": "[間違えないで!]南ことり",
"rarity": 1
},
{