How to extract the item points in this html code with bs4?

<ul class="sheshi_zb">
                                            <li class="jiaotong_color"><span></span>10;106120</li>                                                        <li><span></span></li>                            <li><span></span></li>                            <li><span></span></li>                                                    <li><span></span></li>                        <li><span></span></li>                        <li><span></span></li>                        <li><span></span></li>                        <li><span></span></li>                        <li><span></span></li>                                                            </ul>

surrounding facilities
Traffic: bus No. 10 gets off at Bu Xi Road North Yangtou Station; Bus 106,120 get off at Liaohe No. 1 Experimental Middle School Station
Kindergarten: Yangtou Kindergarten
Primary and Middle School: Jimo Experimental High School
University: Jimo Radio and Television University
Comprehensive Shopping Mall: Liqun, Jialejia
Hospital: medical Center
Bank: industrial and Commercial Bank, Construction Bank
Postal savings
other: Longquan Lake Park, Mengwangshan Park
District: express cabinets, supermarkets, cultural centers for the elderly

the code of this Html is the content of a ul class= "sheshi_zb", but it is divided into different li tags. What should I do if I want to extract the corresponding content?

Mar.20,2021


from bs4 import BeautifulSoup
html='html'
soup = BeautifulSoup(html,'lxml')
list_span=[]
list_li=[]
-sharpspan
for each_span in soup.select('span'):
    list_span.append(each_span.text)
-sharpli
for each_li in soup.select('li'):
    list_li.append(each_li.text)
-sharplist,
for i in range(len(list_span)):
    print(list_span[i]+':'+list_li[i])
    

I don't know if this will solve your problem. If you have any questions, please feel free to ask.

Menu