擅长:python、mysql、java
<p>将代码替换为:</p>
<pre><code>from bs4 import BeautifulSoup
html = '''<tr>
<td>
<a>xyz</a>
</td>
<td>address</td>
<td>phone number</td>
</tr>'''
soup = BeautifulSoup(html, 'lxml')
required = soup.find('a', text = 'xyz')
print(required.text)
td = required.parent
siblingsArray = td.find_next_siblings()
for siblings in siblingsArray:
print(siblings.text)
</code></pre>
<p>订单号:</p>
<pre><code>xyz
address
phone number
</code></pre>
<p>其中<code>parent</code>是Get immediate parent标记,<code>find_next_siblings</code>返回下一个同级标记的列表。你知道吗</p>