Issue
I'm scraping an html document that contains two 'hooks' of the same class like below:
<div class="multiRow">
<!--ModuleId 372329FileName @swMultiRowsContainer-->
<some more content>
</div>
<div class="multiRow">
<!--ModuleId 372330FileName @multiRowsContainer-->
<some more content>
</div>
When I do:
mr = ct[0].find_all('div', {'class': 'multiRow'})
I only get contents from the first Is there a way to get access to contents within the second ?
Thanks!
Solution
Edit with Adam Smith's comment.
Refer to my comment above, code below:
from bs4 import BeautifulSoup as soup
a = "<div class=\"multiRow\"><!--ModuleId 372329FileName @swMultiRowsContainer-->Bye</div> <div class=\"multiRow\"><!--ModuleId 372330FileName @multiRowsContainer-->Hi</div>"
print soup(a).find_all("div",{"class":"multiRow"})[1]
returns:
<div class="multiRow"><!--ModuleId 372330FileName @multiRowsContainer-->Hi</div>
Answered By - sihrc
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.