KOTA ITO

Generation

generate functionFri, 16 Dec 2022

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

from bs4 import BeautifulSoup import requests def get_data(url): res = requests.get(url) soup = BeautifulSoup(res.content, 'html.parser') return soup.find('td', attrs={'class': 'td_count'}).text get_data('https://chord-songs.com/chord/piano/artists/8650')

Questions about programming?Chat with your personal AI assistant