막짠 숙제 제출
155
레오
작성한 질문수 4
0
강의가 거의 끝나가네요.
막짜서 구현(이라도) 할 수 있는 수준까지 왔어요 감사합니다.
from bs4 import BeautifulSoup
# setting
field_value = tuple(["등록번호", "등록일자", "출원번호", "출원일자", "상태", "특허제목"])
data_list = []
data_list.append(field_value)
# read xml file
with open("ipa110106.XML", "r", encoding="utf8") as xml_file:
xml = xml_file.read()
# seperate xml
xml_list = xml.split('<?xml version="1.0" encoding="UTF-8"?>\n')
# remove empty str
while 1:
if "" in xml_list:
xml_list.remove("")
else:
break
# extract info
for page in xml_list:
# extract info from xml
soup = BeautifulSoup(page, "lxml")
publication_reference_tag = soup.find("publication-reference")
application_reference_tag = soup.find("application-reference")
p_document_id_tag = publication_reference_tag.find("document-id")
a_document_id_tag = application_reference_tag.find("document-id")
p_doc_number = p_document_id_tag.find("doc-number").get_text() # 등록번호
p_date = p_document_id_tag.find("date").get_text() # 등록일자
a_doc_number = a_document_id_tag.find("doc-number").get_text() # 출원번호
a_date = a_document_id_tag.find("date").get_text() # 출원일자
p_kind = p_document_id_tag.find("kind").get_text() # 상태
invention_title = soup.find("invention-title").get_text() # 특허제목
# make data_list
data_list.append(tuple([p_doc_number, p_date, a_doc_number,
a_date, p_kind, invention_title]))
# write data on csv
with open("data.csv", "w", encoding="utf8") as data_csv:
for patent in data_list:
data_csv.write(",".join(patent) + "\n")
답변 1
atom warning 글
0
337
0
backend.ai 설치 오류
0
315
0
backend.ai 설치 시 에러 발생
0
740
1
과제 제출 시 hash key is already used 문제 발생
0
445
0
install.bat 오류
0
478
0
과제 제출 시 hash key is already used. 해시키 문제 문의 드립니다.
0
308
1
"Hash key is already used."으로 인한 과제 제출 실패 문의
0
303
1
과제 제출 시 에러가 발생합니다
0
271
1
인트로 강의가 없습니다
0
180
0
사진 링크가 깨져있습니다
0
270
0
slack아직 사용할 수 있는건가요?
0
173
0
강의자료
0
398
4
'backend.ai'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다.
0
438
2
에러확인부탁드립니다.
0
258
1
number of cases 코드 질문
0
206
1
split 관련 질문입니다!
0
229
1
함수 definition 관련 질문입니다.
0
296
1
is_digit 함수 구현
0
306
1
Map & Reduce 강의 8분 15초
1
233
1
keyword parameter
0
239
1
submit.bat 오류
0
196
2
matrix_transpose 결과값이 뭐죠?
0
176
0
value를 넣으면 key를 반환하는 함수
0
131
0
첨부파일의 unit test는 어떻게 사용하나요?
0
267
0





