KOTA ITO

Generation

generate functionFri, 16 Dec 2022

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

def get_tweet_text(url): html = requests.get(url) soup = BeautifulSoup(html.text, "html.parser") text = soup.select_one("#rankingChart > tbody > tr:nth-child(22) > td") return text.get_text()

Questions about programming?Chat with your personal AI assistant