Python爬虫模拟登录(四):BeautifulSoup,爬取数据

登陆成功后爬取我们想要的数据;

用到的库:BeautifulSoup

使用参考:Python爬虫利器二之Beautiful Soup的用法

官方文档:Beautiful Soup 4.2.0 文档               


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)

输出


猜你喜欢

转载自blog.csdn.net/M_N_N/article/details/80716147