Home>

I am doing web scraping using selenium.
I can get the information I want, but I want to change the appearance of the output characters, but I can't change it properly.
Specifically, I want to display "6 people" that have been divided so that 6 people are lined up side by side.

It will be acquired like the image below.
The HTML structure is as shown in the image.

The code looks like this:

from selenium import webdriver
from bs4 import BeautifulSoup
driver_path="path"
Operate #Chrome
driver = webdriver.Chrome(driver_path)
driver.get(url)

html = driver.page_source.encode('utf-8')
# Parse so that it can be handled by Beautiful Soup
soup = BeautifulSoup(html, "html.parser")
msg = soup.select_one("#app>div>div>div.mainContainer>div>div>div.row.DataBlock>div:nth-child(10)>div>header>div>div:nth-child(3 )>span").text
print(msg)
Error message
Applicable source code
Source code
What I tried

Please describe what you have tried for the problem here.

Supplemental information (FW/tool ​​version, etc.)
  • Answer # 1

    I'm not sure what I did,"6 people"If you want to get the data

    import re
    msg = re.sub(r"\s","",msg)