Beautiful Soup web scraping first character a point


I tried to scrape this:

<table class="info">
<tr class="info"><th align="center" class="info" colspan="2">Nachrichten zum Tag</th></tr>
<br/>.</td></tr>><td class="info" colspan="2">Information: Room.
<br/>.</td></tr>2023   07:45 Uhr. colspan="2">Update:
<br/>.</td></tr>><td class="info" colspan="2">Heute.

with beautiful soup and this function: soup.get_text() but the first letter becomes a .

.nformation: Room. .r., 27.01.2023 07:45 Uhr. .eute.

expected output:
Information: Room. Update: Heute.

Asked By: Konsti_x08



First, the HTML script seems to be damaged.

I think the correct HTML you need is.

<table class="info">
<tr class="info">
    <th align="center" class="info" colspan="2">Nachrichten zum Tag</th>
    <td class="info" colspan="2">Information: Room. </td>
    <td class="info" colspan="2">Update: Heute. </td>

Beautiful soup will behave the way you want it to with this HTML.

Answered By: SW Jeong
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.