Python从网页中提取所有无序列表

Python从网页中提取所有无序列表,python,Python,大家好,我用这个代码来获取网页的html代码。 我需要从中提取所有无序列表标签。。。更快更简单的方法是什么 #test.py import requests req = requests.get('http://www.example.com') print 'Response Code: ' + str(req.status_code) print '\nResponse:\n' + req.text 看看beautifulsoup。 import urllib, bs4 pages =

大家好,我用这个代码来获取网页的html代码。 我需要从中提取所有无序列表标签。。。更快更简单的方法是什么

#test.py
import requests
req = requests.get('http://www.example.com')
print 'Response Code: ' + str(req.status_code)
print '\nResponse:\n' + req.text

看看beautifulsoup。
import urllib, bs4

pages = bs4.BeautifulSoup(urllib.urlopen(your_url).read())
lists = pages('ul') # your list of unordered list elements
import urllib2
from bs4 import BeautifulSoup

html_page = urllib2.urlopen("http://example.com")
soup = BeautifulSoup(html_page)
li = soup.select("ul")

print li