Skip to content
Advertisement

How to iterate in each element?

JavaScript

We need to take the stocks with BeautifulSoup. Code only iterates the first element. How to iterate each one?

Advertisement

Answer

First find all ul elements and iterate over it to find title and values according to class wise and append items to dict1 with key title

JavaScript

Now you can use pandas module to transform data to DataFrame using pd.DataFrame method and get data according to required

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement