我推荐一个非常好的工具,叫做 re,你可以从两个子字符串中搜索特定的字符串,例如import res = ''<td>THERE IS TEXT I WANT TO GET</td>"result = re.search('<td>(.*)</td>', s)print(result.group(1))
>>> html="<td>THERE IS TEXT I WANT TO GET</td>\n<td>THERE IS TEXT I WANT TO GET</td>\n<td>THERE IS TEXT I WANT TO GET</td>\n<td>THERE IS TEXT I WANT TO GET</td>">>> soup = BeautifulSoup(html)>>> for td in soup.find_all('td'): print(td.text)