import os
import urllib

import requests
#import wx
import time

from fake_useragent import UserAgent
from lxml import etree
from urllib import request

ua = UserAgent()
headers ={
'user-agent': ua.random
}
opener=urllib.request.build_opener()
opener.addheaders=[('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1941.0 Safari/537.36')]
for i in range(2, 7):
url = "https://www.fb532.com/tupian/list-清纯唯美-%d.html"%i
print(url)

#https://www.fb532.com/tupian/list-%E6%B8%85%E7%BA%AF%E5%94%AF%E7%BE%8E-3.html
#url = "https://www.128nm.com/"
response = requests.get(url,headers = headers)
print(url)
html = response.content.decode("utf-8")
content = etree.HTML(html)

li_list = content.xpath('//ul[@class="clearfix"]/li')
print(li_list)
print(len(li_list))
for li in li_list:
img_name = li.xpath('./a/@title')[0]
print(img_name)
img_url = li.xpath('./a/@data-original')[0]
# print("url:" + img_url)
print(img_name, img_url)
styles = img_url.split(".")
laststyle = styles[len(styles)-1]
print(img_url)
path = "imgs3"
if not os.path.exists(path):
os.mkdir(path)

filename = path + "/" + img_name + "."+laststyle

print(filename)
urllib.request.install_opener(opener)
urllib.request.urlretrieve(img_url, filename)

Python-demo(photo)的更多相关文章

  1. CentOS thrift python demo

    编辑接口文件 hellowworld.thrift service HelloWorld { string ping(), string say(1:string msg) } 编辑 server.p ...

  2. python demo整理

    1 变量作用域 #!/usr/bin/python # coding=utf-8 name = "whole global name" class Person: name = & ...

  3. Python demo working

    一.游戏1.2.3 print("-------------- Guess Number Game---------------------") num=input("G ...

  4. appium python demo

    #coding=utf-8from appium import webdriverdesired_caps={}desired_caps["platformName"]=" ...

  5. rabbitmq python demo 参考链接地址

    链接地址: https://docs.openstack.org/oslo.messaging/latest/reference/server.html https://www.cnblogs.com ...

  6. appium+Python真机运行测试demo的方法

    appium+Python真机运行测试demo的方法 一,    打开手机的USB调试模式 二,    连接手机到电脑 将手机用数据线连接到电脑,并授权USB调试模式.查看连接的效果,在cmd下运行命 ...

  7. 第一个 Python 程序 - Email Manager Demo

    看了一些基础的 Python 新手教程后,深深感觉到 Python 的简洁与强大,这是我的第一个 Python Demo.下面是完整代码与执行截图. 代码: # encoding: utf-8 ''' ...

  8. pyhanlp python 脚本的demo补充

    java demo https://github.com/hankcs/HanLP/tree/master/src/test/java/com/hankcs/demo github python de ...

  9. 【Python五篇慢慢弹(5)】类的继承案例解析,python相关知识延伸

    类的继承案例解析,python相关知识延伸 作者:白宁超 2016年10月10日22:36:57 摘要:继<快速上手学python>一文之后,笔者又将python官方文档认真学习下.官方给 ...

  10. Eclipse中Python开发环境搭建

    Eclipse中Python开发环境搭建  目 录  1.背景介绍 2.Python安装 3.插件PyDev安装 4.测试Demo演示 一.背景介绍 Eclipse是一款基于Java的可扩展开发平台. ...

随机推荐

  1. 不同版本2.5的Servlet web.xml 头信息

    <?xml version="1.0" encoding="UTF-8"?> <web-app version="2.5" ...

  2. 关于ArcGIS api for JavaScript的一些内容

    2018-3-19 ArcGIS api for JavaScript 在3.4之后就已经抛弃了过时的写法,采用了AMD的写法,AMD规范即异步模块加载机制,这种规范让JS就像其它面向对象语言(比如J ...

  3. 利用 ssh 传输文件

    前提条件: 服务器要开启写入权限: 本地和服务器都要安装有 scp 包: 如何传输: 1. 从服务器上下载文件: scp username@servername:远程目录/文件名 本地目录 例:scp ...

  4. 必懂的webpack高级配置

    webpack高级配置 1.HTML中img标签的图片资源处理 使用时.只需要在html中正常引用图片即可.webpack就会找到对应的资源进行打包.并修改html中的引用路径 主要是将html中的i ...

  5. 记一次搭建ftp服务器的简略经历

    需求:在linux中搭建一个ftp 服务器,用户为:user1 目录为 /data/use1  ,          安全设置:限制权限,只能访问自己目录,限制端口,只允许特定ip访问. 1,安装vs ...

  6. the license has been canceled

    ideal 的 注册码并没有失效,却显示这个信息 the license has been canceled 如果用的是Windows系统,在hosts文件添加下边的ip及映射 0.0.0.0 acc ...

  7. 使用钉钉对接禅道的bug系统,实现禅道提的bug实时在钉钉提醒并艾特对应的开发人员处理

    现在公司测试中有一个痛点是每次测试人员提完bug后,需要定期去提醒开发人员查看禅道的bug记录及修复bug. 导致测试人员在项目测试中不仅要测试整个软件,还要负起实时监督提醒功能的“保姆角色”,身心疲 ...

  8. 【iOS】Your account already has a valid ios

    打包内测的时候遇到了这个问题,如图所示: 官网解决办法: If the certificate already exists in Member Center, a “Your account alr ...

  9. centos6.5-7编译安装Ansible详细部署

    一.基础介绍==========================================================================================ansi ...

  10. 【NOI 2015】程序自动分析 并查集与离散化处理

    题目描述 在实现程序自动分析的过程中,常常需要判定一些约束条件是否能被同时满足. 考虑一个约束满足问题的简化版本:假设x1,x2,x3,-代表程序中出现的变量,给定n个形如xi=xj或xi≠xj的变量 ...