python3用BeautifulSoup抓取图片地址

# -*- 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)
时间: 2024-12-10 01:52:26

python3用BeautifulSoup抓取图片地址的相关文章

python3用BeautifulSoup抓取id='xiaodeng',且正则包含‘elsie’的标签

# -*- coding:utf-8 -*- #python 2.7 #XiaoDeng #http://tieba.baidu.com/p/2460150866 #使用多个指定名字的参数可以同时过滤tag的多个属性 from bs4 import BeautifulSoup import urllib.request import re #如果是网址,可以用这个办法来读取网页 #html_doc = "http://tieba.baidu.com/p/2460150866" #req

python3用BeautifulSoup抓取a标签

# -*- 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.reques

python3用BeautifulSoup抓取div标签

# -*- coding:utf-8 -*- #python 2.7 #XiaoDeng #http://tieba.baidu.com/p/2460150866 #标签操作 from bs4 import BeautifulSoup import urllib.request import re #如果是网址,可以用这个办法来读取网页 #html_doc = "http://tieba.baidu.com/p/2460150866" #req = urllib.request.Req

ffmpeg 从视频流中抓取图片

从视频中不断抓取图片的基本流程:打开视频流地址->获取视频流packt->解码成图片帧->输出图片 一.初始化Ffmpeg void ffmpegInit(){ av_register_all(); avformat_network_init(); av_log_set_level(AV_LOG_ERROR); } 如果你不想输出log,设置log级别为AV_LOG_PANIC. 二.打开视频. int Open(char* url) { context = avformat_alloc

Phantomjs+Nodejs+Mysql数据抓取(2.抓取图片)

概要 这篇博客是在上一篇博客Phantomjs+Nodejs+Mysql数据抓取(1.抓取数据) http://blog.csdn.net/jokerkon/article/details/50868880 后进行的第二部分,请各位读者在看这篇博客之前先浏览上一篇,因为这里面有部分代码会沿用到上一部分的抓取结果. 好,现在开始正式的抓取图片的讲解 首先,我们先来看看代码: var page =require('webpage').create(); var address='http://pro

网络爬虫(专门抓取图片)

xmfdsh我真是兴趣多多,怎么老是静不下心来搞定一方面的技术,再学点其他的东西,循序渐进,好吧,我又研究网络爬虫去了,这是一个简单版的,参考了网上很多资料,C#来编写,专门抓取图片,能够抓取一些需要cookie的网站,所以功能上还是挺完善的,xmfdsh只研究了三天,因此还有大把需要改进的地方,日后再 慢慢改进,在本文后面附上整个项目,在此献给喜欢研究C#的朋友们,让我慢慢地道来: #region 访问数据 + Request(int index) /// <summary> /// 访问数

BeautifulSoup抓取门户网站上的链接

使用BeautifulSoup抓取门户网站上的所有跳转链接 from bs4 import BeautifulSoup import urllib2 request = urllib2.Request('http://www.163.com') response = urllib2.urlopen(request) html_doc = response.read() soup = BeautifulSoup(html_doc , from_encoding = "gb18030")

curl 抓取图片

/** * curl 抓取图片 * @param $url * @return mixed */ public static function downLoadImage($url) { $header = array('Expect:'); $ch = curl_init(); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt(

Python3利用BeautifulSoup4抓取站点小说全文的代码

再写一个用BeautifulSoup抓站的工具,体会BeautifulSoup的强大. 根据小说索引页获取小说全部章节内容并在本地整合为小说全文.不过不是智能的,不同的站点对代码需要做相应的修改. #!/usr/bin/env python import os import sys import re import time import chardet import urllib.request as ur from urllib.parse import urljoin,urlparse f