擅长:python、mysql、java
<pre><code>from bs4 import BeautifulSoup
import requests
r = requests.get('https://www.theswiftcodes.com/united-states/')
soup = BeautifulSoup(r.text, 'lxml')
rows = soup.find(class_="swift").find_all('tr')
th = [th.text for th in rows[0].find_all('th')]
print(th)
for row in rows[1:]:
cell = [i.text for i in row.find_all('td', colspan=False)]
print(cell)
</code></pre>
<p>输出:</p>
^{pr2}$