위키 피 디아의 고귀한 계시록 목록에서 테이블을 추출하려고했습니다.이 테이블에는 아무런 가치가 없습니다. 그 값을 처리하는 방법을 알지 못합니다. 셀을 반복하면서 어떻게 할 수 있습니까? 표에 none 값을 포함 시키십시오. 위키 백과 페이지에 링크입니다 : https://en.wikipedia.org/wiki/List_of_Nobel_laureates파이썬을 사용하는 웹 스크래핑 테이블
import requests
from bs4 import BeautifulSoup
import pandas as pd
r=requests.get('https://en.wikipedia.org/wiki/List_of_Nobel_laureates')
soup=BeautifulSoup(r.text, 'html.parser')
table = soup.find('table', class_='wikitable')
rows = table.find_all('tr')
del rows[0]
for row in rows:
cells=row.find_all('td')
records=[]
print(cells)
year = cells[0].text
print("contents",cells[1].contents[1].text)
physics_winner = cells[1].contents[1].text
physics_url = cells[1].find('a')['href']
예상되는 출력은 얼마입니까? –
내 결과물은 모든 귀족 계급의 수상자와 그들의 규율, 각자의 URL과 그들이받은 상금을받은 csv 파일이어야합니다. – Aamir
'wikitablescrape'을 시도 했습니까? 파이썬 패키지 –