๋ฐ์ํ
๊ตฌ๊ธ์์ ํฌ๋กฌ์ ๋๋ฆฌ๋ฉด, ์ด๋ฐ ์๋ฌ๊ฐ ๋ฐ์ํ๋๋ฐ
๊ตฌ๊ธ ํฌ๋กฌ ๊ฐ๋ฐ์๋๊ตฌ์์ ๋ฌด์์ css selector copy๋ฅผ ์คํํด์ ๋์ค๋ child ์ ํ์์ธ nth-child ๋ ์ธ์์ด ์๋๋ค๊ณ ....
: ํ์๊ฐ ์๋, - ํ์๋ก ๋ฐ๊ฟ์ค๋ค
์ฝ๋ก ์ ๋ฒ๋ฆฌ๊ณ nth-of-type ์ผ๋ก ์ ๋ถ ๋ถ์ฌ์ ์์ฑํ๋ค nth of type
tr:nth ->nth-of-type ์ผ๋ก ๋ฐ๊ฟ์ค๋ค.
๊ธฐ์กด์ ์ฝ๋
comments = soup.select('#count > yt-formatted-string > span:nth-chile(2)')
๋ณ๊ฒฝํ ์ฝ๋
# ๋๊ธ ์ , ์คํฌ๋กค๋ฐ๋ฅผ ๋ด๋ ค์ผ ๋ณด์
comments = soup.select('#count > yt-formatted-string > span:nth-of-type(2)')
comments
๊ฒฐ๊ณผ
[<span class="style-scope yt-formatted-string" dir="auto">4</span>]
๋ฐ์ํ
'๐๏ธ์ํํธ์จ์ด > ๐ปpython' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
jupyter_notebook_config.json error ์๋ฌ ์์ธ ๋ฐ ํด๊ฒฐ ๋ฐฉ๋ฒ (0) | 2021.11.26 |
---|---|
ํฌ๋กค๋ง ์ ๋ ๋ ๊ธฐ๋ฅ๋ค - ํฌ๋กค๋ฌ ๊ธฐ๋ณธ ์ฌ์ฉ๋ฒ (0) | 2021.11.26 |
์ ํ๋ธ ์ฌ์ดํธ ํฌ๋กค๋ง(๋งํฌ, href) (0) | 2021.11.25 |
'list' object has no attribute 'find_all' ์๋ฌ (0) | 2021.11.25 |
[Python] TypeError: 'NoneType' object is not iterable ์ค๋ฅ ํด๊ฒฐ ๋ฐฉ๋ฒ (0) | 2021.11.25 |