我已经浏览了很多关于bs4和获取html元素的帖子,然而,当我试图获得嵌套元素时,我试图获得嵌套元素,在这种情况下,我没有运气。
HTML
http://image.prntscr.com/image/3e3b1eb455734d98b236f89c561f6f56.png
with requests.Session() as c:
url = 'https://firefly.clevedonschool.org.uk/login/login.aspx?prelogin=http%3a%2f%2ffirefly.clevedonschool.org.uk%2f'
USERNAME = 'usr'
PASSWORD = 'pass'
c.get(url)
login_data = dict(username=USERNAME, password=PASSWORD)
c.post(url, data=login_data, headers={"Referer": "https://firefly.clevedonschool.org.uk"})
tasks = c.get("https://firefly.clevedonschool.org.uk/tasks")
print tasks.content
soup = bs(urllib2.urlopen("https://firefly.clevedonschool.org.uk/tasks").read(), "html.parser")
tasks_list = soup.findAll('li', class_="ff-task")
print tasks_list
从中返回的是[]
示例li元素:hastebin.com/tosajugewe.js
上面链接的是html,你可以看到我想要的li / s。
任何帮助将不胜感激。