작성
·
145
0
import requests
import re
from bs4 import BeautifulSoup
url = "https://unipass.customs.go.kr/csp/index.do"
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36"}
res = requests.get(url, headers = headers)
res.raise_for_status()
soup = BeautifulSoup(res.text, "lxml")
print(res.text)
#soup.find("div",{"id"="MYC0401004Q_table1"}), attrs={"class":"gird_list"}.find("tbody").find_all("tr")
data_row = soup.find("table",{"id":"MYC0401004Q_table1"}).find("tbody").find_all("tr")
for row in data_row:
columns = row.find_all("td")
data = [column.get_text() for column in columns]
print(data)
답변