# -*-  conding=utf-8 -*-

 import  requests
from bs4 import BeautifulSoup
import io url = "https://www.mzitu.com/164871"
#Referer = ? 是模拟电脑操作
headers = {"Referer":"https://www.mzitu.com/164871","User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"}
html = requests.get(url)
soup = BeautifulSoup(html.content,'lxml')
text = soup.find_all("span")[10].text
print(text)
title = soup.find("h2",class_='main-title').text
#获取图片的地址
for i in range(1,10):
#herf 为访问的地址
herf = url +'/'+ str(i)
#在次解析新的url(这个url就是妹子的连接)
html = requests.get(herf,headers=headers)
beautiful = BeautifulSoup(html.text,'lxml')
#获取妹子的图片连接
pic_url = beautiful.find('img',alt=title)
print(pic_url)
html = requests.get(pic_url['src'],headers=headers)
# print(html.content)
# file_name = pic_url['src'].split(r'/')[-1]
"
# print(file_name) f = open(str(i)+'.jpg','wb') # 名称
f.write(html.content) #写入图片
f.close()

python-python爬取妹子图片的更多相关文章

  1. python 3 爬取百度图片

    python 3 爬取百度图片 学习了:https://blog.csdn.net/X_JS612/article/details/78149627

  2. Python:爬取网站图片并保存至本地

    Python:爬取网页图片并保存至本地 python3爬取网页中的图片到本地的过程如下: 1.爬取网页 2.获取图片地址 3.爬取图片内容并保存到本地 实例:爬取百度贴吧首页图片. 代码如下: imp ...

  3. python爬虫-爬取百度图片

    python爬虫-爬取百度图片(转) #!/usr/bin/python# coding=utf-8# 作者 :Y0010026# 创建时间 :2018/12/16 16:16# 文件 :spider ...

  4. Python的scrapy之爬取妹子图片

    闲来无事,做的一个小爬虫项目 爬虫主程序: import scrapy from ..items import MeiziItem class MztSpider(scrapy.Spider): na ...

  5. Python简单爬取Amazon图片-其他网站相应修改链接和正则

    简单爬取Amazon图片信息 这是一个简单的模板,如果需要爬取其他网站图片信息,更改URL和正则表达式即可 1 import requests 2 import re 3 import os 4 de ...

  6. scrapy框架爬取妹子图片

    首先,建立一个项目#可在github账户下载完整代码:https://github.com/connordb/scrapy-jiandan2 scrapy startproject jiandan2 ...

  7. Python爬虫爬取网页图片

    没想到python是如此强大,令人着迷,以前看见图片总是一张一张复制粘贴,现在好了,学会python就可以用程序将一张张图片,保存下来. 今天逛贴吧看见好多美图,可是图片有点多,不想一张一张地复制粘贴 ...

  8. 【Python】爬取网站图片

    import requests import bs4 import urllib.request import urllib import os hdr = {'User-Agent': 'Mozil ...

  9. python保存爬取的图片

    用爬虫抓取图片的保存 保存图片 request=urllib2.Request(randNumberUrl,data,headers) picture=opener.open(request).rea ...

  10. 使用Python批量爬取美女图片

    运行截图 实列代码: from bs4 import BeautifulSoup import requests,re,os headers = { 'User-Agent': 'Mozilla/5. ...

随机推荐

  1. spring aop,静态及动态代理例子

    @Aspect@Componentpublic class AopText { @Pointcut("execution(public * com.llf.service.*Service. ...

  2. USDT/BTC/ETC/HT的解释

    USDT 泰达币 泰达币(USDT)是Tether公司推出的基于稳定价值货币美元(USD)的代币Tether USD(下称USDT),1USDT=1美元,用户可以随时使用USDT与USD进行1:1兑换 ...

  3. Gradle Goodness: Add Incremental Build Support to Custom Tasks with Annotations

    In a previous post we learned how we can use the inputs and outputs properties to set properties or ...

  4. 获取 iOS APP 内存占用的大小

    当我们想去获取 iOS 应用的占用内存时,通常我们能找到的方法是这样的,用 resident_size:   #import <mach/mach.h> - (int64_t)memory ...

  5. python 输入一个字符,是小写转换为大写,大写转换为小写,其他字符原样输出

    s = input('请输入一个字符:') if 'a' <= s <= 'z': print(chr(ord(s) - 32)) elif 'A' <= s <= 'Z': ...

  6. vue 父子组件的生命周期顺序

    一.加载渲染过程 父beforeCreate->父created->父beforeMount->子beforeCreate->子created->子beforeMount ...

  7. Qt图标自定义

    https://mp.csdn.net/postedit/83449333   参考连接

  8. Jquery实现表单动态加减、ajax表单提交

    一直在搞Java后台开发,记得刚工作那一两年时间搞过前后端交互开发,用的东西也是五花八门,当时觉得做页面展示给别人看,是很有成就的事情,不过现在感觉自己跟纯前端开发比起来弱爆了,不过如果你的目标是作为 ...

  9. mybatis xml文件 -- 报错 invalid comparison: java.time.LocalDateTime and java.lang.String

    原配置写法:<if test="assetFlaw.handleTime != null and assetFlaw.handleTime != ''"> and af ...

  10. PL/SQL报错:ORA-28000:the account is locked

    第一种方法(图形操作):第一步:使用PL/SQL,登录名为system,选择类型的时候把Normal修改为SYSDBA:第二步:选择users下的system,右击点击“编辑”: 第三步:修改密码,把 ...