2024-09-30 18:25:00 发布
网友
我可以取出第一组<tr>,但如何取出下一组<tr>
<tr>
如何使循环在最后一组<tr>处停止
x = 1 while True : next = re.search("\<tr>(.*?)</tr>" , match).group(0) print next x = x + 1
match在本例中包含我的已爬网表信息
match
search方法将只找到第一个匹配项。必须使用^{}而不是search来查找所有匹配项,例如:
search
matches = re.findall("\<tr>(.*?)</tr>" , my_html) for match in matches: print(match)
也就是说,像@DisplayName提到的那样,使用专门的工具(比如BeautifulSoup)解析HTML可能是更好的选择
search
方法将只找到第一个匹配项。必须使用^{search
来查找所有匹配项,例如:也就是说,像@DisplayName提到的那样,使用专门的工具(比如BeautifulSoup)解析HTML可能是更好的选择
相关问题 更多 >
编程相关推荐