1. 程式人生 > >Python爬蟲模擬登入(四):BeautifulSoup,爬取資料

Python爬蟲模擬登入(四):BeautifulSoup,爬取資料

登陸成功後爬取我們想要的資料;

用到的庫:BeautifulSoup

F12檢視網頁結構;     


程式碼,依次向下找節點;

def getInfo(html):
    soup = BeautifulSoup(html, "lxml")
    info = soup.find(class_ = "rightframe02").find(class_ = "resources").find('ul').find_all('li')
    # print(info)
    for it in info:
        print(it.span.string)

輸出