將博客主頁的標題爬下來html
#coding=UTF-8 單行註釋 ''' happy 多行註釋 ''' import re import requests url="http://www.cnblogs.com/Bird-Xu" echotop = requests.get(url) result = re.findall('class="postTitle2".+</a>',echotop.text) for index in range(len(result)): print (result[index]) """ for index in result: print (index) 多行注視 """
outputpython
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9032838.html">LaTeX-01
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9028670.html">ARP協議的理解
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9026869.html">markdown怎麼用?備份一張安裝軟件清單
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9022296.html">解決掩碼產生的問題1.
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9016138.html">[轉]Linux下查看和添加環境變量
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9011924.html">Linux Mint安裝Java jdk
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9009548.html">掩碼產生的問題2
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9008884.html">掩碼產生的問題
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9005761.html">數據包在網絡中傳輸的IP與MAC改變
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9004789.html">JAVA包
class="postTitle2" href="http://www.cnblogs.com/Bird-Xu/p/9000692.html">VLAN相關實驗PT
...markdown
下一步就是怎麼將須要的標題取出來
to be continue網絡