擅长:python、mysql、java
<p>您应该使用<a href="http://www.crummy.com/software/BeautifulSoup/" rel="nofollow">BeautifulSoup</a>。在</p>
<p>使用它,您可以执行以下操作:</p>
<pre><code>import urllib2
from BeautifulSoup import BeautifulSoup
url = # put url here
page = urllib2.urlopen(url)
text = page.read()
page.close()
soup = BeautifulSoup(text)
L = []
for x in soup.findAll('li'):
link = x.a
if link.has_key('title'):
if len(link['title']) == 4:
L.append(link['title'])
print L
</code></pre>