Issue
I want extract odds from a website. Underneath you can see my code. I've used .find_all() to find the div tags with the class = odd_value where the odds are located between span tags. When I append it to the list it copies all of the elements to the list as one index.Here is my code where I have printed the length of the list, to show you my problem
How do I copy each div tag with the class = odd_value as seperate indexes instead of just one big index, to my list: listOdds
Solution
.find_all()
returns a ResultSet (subclass of a list) of matched filters, and you are appending that to another list using .append()
therefor your list becomes [[<div ..., <div ..., ...]]
and the length of that is 1.
So to fix that you can simply assign it to listOdds
variable like this:
listOdds = sovs.find_all("div", {"class": "odd_value"})
Or to make it joinable you can convert each item to string by doing:
listOdds = list(map(str, sovs.find_all("div", {"class": "odd_value"})))
Answered By - zamir
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.