bs4での文字列検索
解決したいこと
passageの中のabstractのテキストにfirstまたはsecondが含まれていたら、textを返すプログラムなんですが、このor条件をadd条件にしたいのですが分からなかったので教えて頂きたいです.
該当するソースコード
for body in file_read_generator('1.xml', '<document>', '</document>'):
soup = BeautifulSoup(body,features= "lxml")
texts = soup.select(f'''
passage >
infon[key="type"]:-soup-contains("abstract") ~ text:-soup-contains("first","second")
''')
text=[]
for t in texts:
text.append(t.text)
0 likes