python - parsing HTML using BeautifulSoup -


I want to read a list on the webpage using the BeautifulSuices module in Python. The HTML code is as follows:

  ...   

I parse the document using BeautifulSoup. Now I want to loop through the elements of the list. That's why I use the next_ variations as follows:

  Soup.all.lnct_shiibing for item's first_aliment = soup.all .: lt; Statement & gt;   

However, it returns the following error:

  TypeError: The 'NoneType' object is not iterable   

Can Please tell me how to read the next lee tag. It is obvious that there is another Li tag at the same level, which should be in the list of the next_shipping.

P> Borrowing @ Elssar, I used this code:

  main_list = soup.find ('ul', attrs = {'id': 'sidebarmenu1'} li li Main_list.findAll ('li', Attrs = {}, recursive = falls): ul = l.find ('ul') if ul == none: #more: navigate (ul)  < / Pre> 

Where to navigate (item) is a recurring function: def Navigate (item): Select items for All ('li', etters = {}, recursive = falls): ul = confront ('ul') if (ul == none): #do something else: navigate (ul) < / Pre>

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -