码迷,mamicode.com
首页 > 编程语言 > 详细

00009 python3爬虫简单实例

时间:2019-10-31 13:46:16      阅读:73      评论:0      收藏:0      [点我收藏+]

标签:parse   col   实例   http   pytho   python3   python   sts   爬虫   

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爬虫简单实例

标签:parse   col   实例   http   pytho   python3   python   sts   爬虫   

原文地址:https://www.cnblogs.com/python-abc/p/11770496.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!