首页 > 编程语言 > 详细

python3用BeautifulSoup抓取图片地址

时间:2016-11-13 21:50:25      阅读:722      评论:0      收藏:0      [点我收藏+]
# -*- coding:utf-8 -*-
#python 2.7
#XiaoDeng
#http://tieba.baidu.com/p/2460150866
#抓取图片地址


from bs4 import BeautifulSoup
import urllib.request


html_doc = "http://tieba.baidu.com/p/2460150866"
req = urllib.request.Request(html_doc)  
webpage = urllib.request.urlopen(req)  
html = webpage.read()


soup = BeautifulSoup(html, html.parser)


#抓取图片地址
#抓取img标签且class为BDE_Image的所有内容
img_src=soup.findAll("img",{class:BDE_Image})
for img in img_src:
    img=img.get(src)   #抓取src
    print(img)

 

python3用BeautifulSoup抓取图片地址

原文:http://www.cnblogs.com/dengyg200891/p/6059798.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!