0

This is my code:

    div_tag = text.find_all("div", {"class": "team-name"})

    teams = []
    for a_finder in div_tag:
        team_tags = a_finder.find_all("a")
        for a_finder in team_tags:
            teams.append(a_finder.get_text("\n", strip=True))

This is some of the output:

    653
    NOSIDE

Here is the HTML:

    <div class="team-name">
          <a href="/team/653/2020">653<br>NOSIDE</a>
    </div>

The output is nice, but I would like to separate the team number and the team name into two separate lists. Ive been able to separate the text before and after the <br> tag using the "\n", strip=True params but I'm unsure how to actually separate the two into a list or var.

Any help would be quite nice.

stikcye
  • 1
  • 2
  • Welcome to SO! Please put your markup as text in the question itself, not an image. See [why not upload images of code when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question). Beyond that, your output doesn't have much relation to the markup so it's hard to tell what you need. Please show a [mcve]. – ggorlen Mar 19 '20 at 03:12
  • Does this answer your question? [Only extracting text from this element, not its children](https://stackoverflow.com/questions/4995116/only-extracting-text-from-this-element-not-its-children) – ggorlen Mar 19 '20 at 03:14

1 Answers1

0

hey guys I was able to fix this by using the .split method, replacing the
tag with a % I was able to separate both sides into their corresponding arrays.

stikcye
  • 1
  • 2