Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Ways to Scrape Table | Tables
Web Scraping with Python

bookWays to Scrape Table

There are a lot of different ways to scrap tables. The method depends on the structure of the table.

You can apply string methods. As you remember, the function find_all() looks through a tag’s descendants and retrieves all descendants that match the parameter. If we apply it to the tag <tr> the result will be a list of contents of each <tr> tag.

1
rows = html.find_all('tr')
copy

You can also do it using XPath:

rows = html.xpath('//tr')

Then we can clean the data and convert it to the DataFrame. This method can be useful if the table has a complex and confusing structure.

question mark

To get tags we can use:

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 2

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Suggested prompts:

Fragen Sie mich Fragen zu diesem Thema

Zusammenfassen Sie dieses Kapitel

Zeige reale Beispiele

Awesome!

Completion rate improved to 4.76

bookWays to Scrape Table

Swipe um das Menü anzuzeigen

There are a lot of different ways to scrap tables. The method depends on the structure of the table.

You can apply string methods. As you remember, the function find_all() looks through a tag’s descendants and retrieves all descendants that match the parameter. If we apply it to the tag <tr> the result will be a list of contents of each <tr> tag.

1
rows = html.find_all('tr')
copy

You can also do it using XPath:

rows = html.xpath('//tr')

Then we can clean the data and convert it to the DataFrame. This method can be useful if the table has a complex and confusing structure.

question mark

To get tags we can use:

Select the correct answer

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 2
some-alt