Beautifulsoup scraping specific table in page with multiple tables

To only get the first table you can use a CSS Selector nth-of-type(1):

import requests
from bs4 import BeautifulSoup

URL = ""

soup = BeautifulSoup(requests.get(URL).content, "html.parser")

table = soup.select_one("table.wikitable:nth-of-type(1)")
trs = table.find_all("tr")

for tr in trs:

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top