import requests
import csv
from bs4 import BeautifulSoup

url = 'https://[Log in to view URL]'

response = requests.get(url)

soup = BeautifulSoup(response.content, 'html.parser')

# 필요한 정보 추출
pokemon_list = []

# https://[Log in to view URL] 페이지에서 바로 추출할 수 있는 넘버, 이름 정보를 리스트에 추가
for item in soup.select('#pokedexlist li'):
    no = item.select('h3 p')[0].text.split('.')[1]
    name = item.select('h3')[0].text.split()[1]
    pokemon_list.append([no, name])

# https://[Log in to view URL] 페이지에서 추출해야하는 분류를 리스트에 추가
for view in range(1,len(pokemon_list)+1):
    typeview = requests.get(url+'view/'+str(view))
    soup_type = BeautifulSoup(typeview.content, 'html.parser')
    type_name = soup_type.select_one('.bx-detail div:nth-child(3) p')
    print(type_name.text)
    pokemon_list[view-1].append(type_name.text)

print(pokemon_list)

# 추출한 정보 .csv 파일로 저장
with open('pokemon_data.csv', mode='w', newline='', encoding='utf-8-sig') as file:
    writer = csv.writer(file)
    writer.writerow(['pno', 'pname', 'categorize'])
    for pno in pokemon_list:
        writer.writerow(pno)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: