파이썬 크롤링 오류 문의드립니다

22.06.29 08:47 작성 조회수 103

0

- 학습 관련 질문을 남겨주세요. 상세히 작성하면 더 좋아요!
- 먼저 유사한 질문이 있었는지 검색해보세요.
- 서로 예의를 지키며 존중하는 문화를 만들어가요.
- 잠깐! 인프런 서비스 운영 관련 문의는 1:1 문의하기를 이용해주세요.
 
 
안녕하세요
파이썬 크롤링 하고 있는데
오류가 안나면 보여지는 화면을 모두 끌어오고
오류가 나면 > AttributeError: ResultSet object has no attribute 'find' 이렇게 뜹니다
 
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)
 
분명 데이터가 있는데 제가 태그를 잘못 가져온 걸 까요? 
몇번을 고치고 다른 방법으로, 태그를 가져왔었는데 
어떻게 수정해야 표를 가져올 수 있을까요... 
 

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!