Access Next Sibling
I am completely new to web parsing with Python/BeautifulSoup. I have an HTML that has (part of) the code as follows:
Solution 2:
Have you looked at dir(page)
or the documentation? If so, how did you miss .find_next_sibling()
?
from bs4 import BeautifulSoup
import urllib2
import re
landingPage = urllib2.urlopen('somepage.com').read()
soup = BeautifulSoup(landingPage)
pageList = soup.find("div", {"id": "pages"})
page = pageList.find("li", {"class": "active"})
sibling = page.find_next_sibling()
Post a Comment for "Access Next Sibling