https://www.youtube.com/watch?v=QLf-pDoJvjQ&list=PLaRYNlxIGoESkuvIdRJNLjdUC4lpF3fM7&index=3&t=0s ================================================================================ Crawling table data ================================================================================ import requests from bs4 import BeautifulSoup # Get HTML data from page r=requests.get("http://lambutan.dothome.co.kr/") # Bring its contents c=r.content # Paser HTML text to HTML format text soup=BeautifulSoup(c,"html.parser") ================================================================================ # Table structure in HTML # tbody # tr # td # td # tr # tr # td # td # tr # tbody ================================================================================ # Use find() when you search HTML by "one tag" # or when you want to get one item from "one tage" # If there are multiples tags, find() return content of first tag # all=soup.find('tbody') # Get all contents inside of tbody # Get one td from multiple td # all=soup.find('td') ================================================================================ all=soup.find("tbody") ================================================================================ # After finding "tbody", you need to find "tr" # You can use soup.find_all() # It stores tags into list # [all[0],all[1],...] ================================================================================ all2=all.find_all("tr",{"class":""}) # all2 # [<tr class="">a</tr>,<tr class="">b</tr>,<tr class="">c</tr>] ================================================================================ # Find td for item in all2: # Find td tage, class name is professor professor=item.find("td",{"class":"professor"}).text lectureName=item.find("td",{"class":"lecture"}).text orther=item.find("td",{"class":"orther"}).text grade = item.find("td",{"class": "grade"}).text evaluation=item.find("td",{"class": "evaluation"}).text print(professor+"/"+lectureName+"/"+orther+"/"+grade+"/"+evaluation) # Kim/Python/None/1/1