KOTA ITO

Generation

generate functionFri, 16 Dec 2022

beaurifulsoupを使って、WEBサイトの中の、 X-path '//*[@id="rankingChart"]/tbody/tr[22]/td' の中にある文字列をすべて取得する

from bs4 import BeautifulSoup import requests url = "https://tv.so-net.ne.jp/chart/7/" html = requests.get(url) soup = BeautifulSoup(html.content, "html.parser") print(soup.select('//*[@id="rankingChart"]/tbody/tr[22]/td'))

Questions about programming?Chat with your personal AI assistant