打开一个url
from urllib.request import urlopen
html = urlopen(url)
解析html元素编程对象
from bs4 import BeautifulSoup
bsobj = BeautifulSoup(html.read())
查找元素
title = bsobj.findAll("img")
查找元素的属性
image[i].attrs['src']
下载文件
from urllib.request import urlretrieve
urlretrieve(img_url, file_name)
网友评论