00009 python3爬虫简单实例

Posted python-abc

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了00009 python3爬虫简单实例相关的知识,希望对你有一定的参考价值。

OS: ubuntu-18.04.1

apt install -y python3-pip pip3 install bs4 pip3 install lxml
#!/usr/bin/env python3

import requests

r = requests.get(http://www.wise.xmu.edu.cn/people/faculty)  
html = r.content

from bs4 import BeautifulSoup  
soup = BeautifulSoup(html, html.parser)

div_people_list = soup.find(div, attrs={class: people_list})  
a_s = div_people_list.find_all(a, attrs={target: _blank})

for a in a_s:  
    url = a[href]  
    name = a.get_text()  
    print(name, url)

 

以上是关于00009 python3爬虫简单实例的主要内容,如果未能解决你的问题,请参考以下文章