KOTA ITO

Generation

generate functionMon, 20 Mar 2023

beautiful soupで、XPATH「///*[@id="left-contents"]/div[1]/div/div/div[1]/div/div[3]/p[2]/text()[3]」に含まれる文字列を取得する。

def get_kimono_text(html): soup = BeautifulSoup(html, "html.parser") node = soup.xpath('//*[@id="left-contents"]/div[1]/div/div/div[1]/div/div[3]/p[2]/text()[3]') if node: return node[0].strip() else: return None

Questions about programming?Chat with your personal AI assistant