此soup.find_all
已返回
[<span class="flight-number sp-g-tooltips" data-bundle2="Flight Details" title="">5J 892</span>, <span class="flight-number sp-g-tooltips" data-bundle2="Flight Details" title="">5J 900</span>, <span class="flight-number sp-g-tooltips" data-bundle2="Flight Details" title="">5J 902</span>]
text1=soup.find_all("span", class_="flight-number sp-g-tooltips")
问题:如何解析内部文本,如5J892 5J900 5J902并存储在数组中?
答案 0 :(得分:0)
text1=soup.find_all("span", class_="flight-number sp-g-tooltips")
lines = [span.get_text() for span in text1]
列表理解将迭代text1
中的每个范围并返回该范围的文本