Python-demo(photo)
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)的更多相关文章
- CentOS thrift python demo
编辑接口文件 hellowworld.thrift service HelloWorld { string ping(), string say(1:string msg) } 编辑 server.p ...
- python demo整理
1 变量作用域 #!/usr/bin/python # coding=utf-8 name = "whole global name" class Person: name = & ...
- Python demo working
一.游戏1.2.3 print("-------------- Guess Number Game---------------------") num=input("G ...
- appium python demo
#coding=utf-8from appium import webdriverdesired_caps={}desired_caps["platformName"]=" ...
- rabbitmq python demo 参考链接地址
链接地址: https://docs.openstack.org/oslo.messaging/latest/reference/server.html https://www.cnblogs.com ...
- appium+Python真机运行测试demo的方法
appium+Python真机运行测试demo的方法 一, 打开手机的USB调试模式 二, 连接手机到电脑 将手机用数据线连接到电脑,并授权USB调试模式.查看连接的效果,在cmd下运行命 ...
- 第一个 Python 程序 - Email Manager Demo
看了一些基础的 Python 新手教程后,深深感觉到 Python 的简洁与强大,这是我的第一个 Python Demo.下面是完整代码与执行截图. 代码: # encoding: utf-8 ''' ...
- pyhanlp python 脚本的demo补充
java demo https://github.com/hankcs/HanLP/tree/master/src/test/java/com/hankcs/demo github python de ...
- 【Python五篇慢慢弹(5)】类的继承案例解析,python相关知识延伸
类的继承案例解析,python相关知识延伸 作者:白宁超 2016年10月10日22:36:57 摘要:继<快速上手学python>一文之后,笔者又将python官方文档认真学习下.官方给 ...
- Eclipse中Python开发环境搭建
Eclipse中Python开发环境搭建 目 录 1.背景介绍 2.Python安装 3.插件PyDev安装 4.测试Demo演示 一.背景介绍 Eclipse是一款基于Java的可扩展开发平台. ...
随机推荐
- [AOP拦截 ]SpringBoot+Quartz Aop拦截Job类中的方法
最近在工作使用boot+quartz整合,开发定时调度平台,遇到需要对Quartz的Job进行异常后将异常记录到日志表的操作,第一反应就想到了使用Spring的AOP,利用AfterThrowin ...
- HTML 去调table表单里面td之间的间距
首先为大家展示一下最原始的代码和效果.直接在table中用td划分的表格会默认隐藏边框. 接下来我们用css来增加样式,为table增加边框. table { border: 1px solid # ...
- 【Java中级】(五)异常处理
1.什么是异常 异常定义:导致程序的正常流程被中断的事件,叫做异常. 2.异常处理 try catch finally throws package exception; import java.io ...
- GCC 编译多个文件
今天写数据结构的example,定义了3个文件:lish.h list.c main.c list.h是list.c的头文件,mian.c中对list.h进行了引用.代码如下: list.h 1 #i ...
- z-index不起作用
摘录自 https://blog.csdn.net/apple_01150525/article/details/76546367 z-index无效的情况,一共有三种:1.父标签 position属 ...
- flink入门实战总结
随着大数据技术在各行各业的广泛应用,要求能对海量数据进行实时处理的需求越来越多,同时数据处理的业务逻辑也越来越复杂,传统的批处理方式和早期的流式处理框架也越来越难以在延迟性.吞吐量.容错能力以及使用便 ...
- 任何类型的数据都向String转型
String从其定义上发现首字母大写,所以此为一个类,属于引用数据类型,但是此类属于系统的类. (1)String像普通变量一样直接通过复制的方式进行声明.字符串使用双引号括起来.两个字符串使用&qu ...
- java中map,set的简单使用
package test2; import java.util.*; import static java.lang.System.out; public class test2 extends St ...
- .Net Core CLR FileFormat Call Method( Include MetaData, Stream, #~)
.Net Core CLR PE 文件启动方法,找到函数入口点,调用整个.Net 程式宿主. 使用方法:可以利用Visual Studio新建一个控制台应用程序,然后生成DLL,替换掉本程序DLL, ...
- 关于报错:The Microsoft.ACE. Oledb.12.0 provider was not registered on the local computer
错误描述:The Microsoft.ACE. Oledb.12.0 provider was not registered on the local computer 最近在Web项目中做一个自动生 ...