05 2019 档案

摘要:import time t = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())) 阅读全文
posted @ 2019-05-27 20:37 乔儿 阅读(129) 评论(0) 推荐(0) 编辑
摘要:可以在直接spider、pipeline和downloaderMiddlewares中关闭爬虫 在spider中时在方法里直接写 在pipeline和downloaderMiddlewares里 虽然这一行代码会停止爬虫,但是这一行代码的停止并不是立即停止 原因是因为当我们不更改爬虫的setting 阅读全文
posted @ 2019-05-24 16:54 乔儿 阅读(860) 评论(0) 推荐(0) 编辑
摘要:在Python中"\"一般是作为转义符用的,即(\d,\t,\n),但是有时候会用到单独的"\"如果直接这么用,那么就会报错,这时候需要双反斜线,"\\",第一个反斜线转义第二个反斜线。这样用就没有错误了。 阅读全文
posted @ 2019-05-23 15:24 乔儿 阅读(1207) 评论(0) 推荐(0) 编辑
摘要:功能:将字符串str当成有效的表达式来求值并返回计算结果。 语法: eval(source[, globals[, locals]]) -> value 参数: source:一个Python表达式或函数compile()返回的代码对象 globals:可选。必须是dictionary locals 阅读全文
posted @ 2019-05-23 14:50 乔儿 阅读(923) 评论(0) 推荐(0) 编辑
摘要:import re re.split(r"[*×]",xg) #这里是根据*或者x来分割的 阅读全文
posted @ 2019-05-21 11:56 乔儿 阅读(858) 评论(0) 推荐(0) 编辑
摘要:t = int(round(time.time() * 1000)) 阅读全文
posted @ 2019-05-17 20:07 乔儿 阅读(1429) 评论(0) 推荐(0) 编辑
摘要:data = {"mobileNo":"15201222502","cityId":"402","userClassId":1,"userDisplayClass":0,"addressId":"","deviceType":3} response = requests.post(url=url,headers=headers,data=json.dumps(data)) 阅读全文
posted @ 2019-05-17 19:57 乔儿 阅读(499) 评论(0) 推荐(0) 编辑
摘要:1、(1241, 'Operand should contain 1 column(s)'),原因是数据类型出现错误,数据库中该字段是str类型,但是要插入的数据类型是list。 2、(1064, "You have an error in your SQL syntax; check the ma 阅读全文
posted @ 2019-05-15 19:52 乔儿 阅读(357) 评论(0) 推荐(0) 编辑
摘要:scrapy框架默认是有去重(重复的请求直接忽略掉)设置的,就是如果多个请求完全相同,那么就会报错“Filtered duplicate request no more duplicates will be shown (see DUPEFILTER_DEBUG to show all duplic 阅读全文
posted @ 2019-05-14 20:58 乔儿 阅读(2113) 评论(0) 推荐(0) 编辑
摘要:SELECT channel, count(*) from crawled_goods where datediff(created_at,NOW())=0 and channel like '%yijiupi%'GROUP BY( channel) 阅读全文
posted @ 2019-05-14 10:53 乔儿 阅读(466) 评论(0) 推荐(0) 编辑
摘要:def extract_cookies(cookie): """从浏览器或者request headers中拿到cookie字符串,提取为字典格式的cookies""" cookies = dict([l.split("=", 1) for l in cookie.split("; ")]) ret 阅读全文
posted @ 2019-05-10 20:42 乔儿 阅读(730) 评论(0) 推荐(0) 编辑
摘要:1、查询某天的数据量: SELECT count(*) from crawled_goods where channel='yijiupi-beijing' and datediff(created_at,NOW()) = -1(0代表今天,-1代表昨天); 2、查询某个时间段的数据量:SELECT 阅读全文
posted @ 2019-05-10 13:34 乔儿 阅读(103) 评论(0) 推荐(0) 编辑
摘要:一个字典通过format()函数转换后就会由dict变为str, 例如: 所以在用的时候需要再将str转为dict,这里用到的转换为eval(), 例如: 附上原链接:https://blog.csdn.net/weixin_40894428/article/details/80683137 阅读全文
posted @ 2019-05-10 10:56 乔儿 阅读(2688) 评论(0) 推荐(0) 编辑
摘要:猜测你的代码是这样的: return Request('http://www.baidu.com', meta={'cookiejar': 1}, callback=self.next1) 有两种解决方法: 1.使用yield, 把return换为yield yield scrapy.Request(self.start_urls, callback=self.parse_link) ... 阅读全文
posted @ 2019-05-10 10:21 乔儿 阅读(459) 评论(0) 推荐(0) 编辑
摘要:例如: 运行这个函数会报错:TypeError: not enough arguments for format string,原因是'Submit': '%sjdf'里面的%在后面的括号中没有定义,所以就会报错not enough argument(没有足够的参数),所以在遇到这种字符串中携带%的 阅读全文
posted @ 2019-05-10 10:08 乔儿 阅读(4588) 评论(0) 推荐(0) 编辑
摘要:[^\d]+代表从不是数字的字符开始匹配,后面的"+"表示有多个元素,(\d.*)表示从数字开始匹配,知道最后一个元素。 第二个表示已非数字结尾,匹配的就是纯数字。 阅读全文
posted @ 2019-05-09 19:54 乔儿 阅读(466) 评论(0) 推荐(0) 编辑
摘要:附上原链接:https://www.cnblogs.com/wangboqi/p/7455240.html 阅读全文
posted @ 2019-05-09 19:48 乔儿 阅读(7957) 评论(0) 推荐(1) 编辑
摘要:如果class下面发送请求时用的是return(return [scrapy.Request(url=url,headers=self.header,body=json.dumps(payload),method="POST",callback=self.parse)]),那么这个方法就不能调用类属 阅读全文
posted @ 2019-05-04 14:01 乔儿 阅读(1873) 评论(0) 推荐(0) 编辑
摘要:for number, lowercase, capital in zip(list1, list2, list3): 阅读全文
posted @ 2019-05-03 17:04 乔儿 阅读(811) 评论(0) 推荐(0) 编辑
摘要:简介:它通过{}和:来代替传统%方式 1、使用位置参数 要点:从以下例子可以看出位置参数不受顺序约束,且可以为{},只要format里有相对应的参数值即可,参数索引从0开,传入位置参数列表可用*列表 2、使用关键字参数 要点:关键字参数值要对得上,可用字典当关键字参数传入值,字典前加**即可 3、填 阅读全文
posted @ 2019-05-02 17:17 乔儿 阅读(6153) 评论(0) 推荐(1) 编辑
摘要:url_rl = "https://www.yijiupi.com/v31/Product/ListProduct" payload = '{"currentPage":1,"data":{"sonCategoryId":"%s","categoryIds":["%s"],"saleModel":-1,"sort":0,"currentPage":1,"pageS... 阅读全文
posted @ 2019-05-02 17:08 乔儿 阅读(1124) 评论(0) 推荐(0) 编辑
摘要:#encoding:utf-8 import math #向上取整(进一) print("math.ceil---") print("math.ceil(2.3) => ", math.ceil(2.3)) print("math.ceil(2.6) => ", math.ceil(2.6)) #向下取整(舍一) print("\nmath.floor---") print("math.fl... 阅读全文
posted @ 2019-05-02 15:46 乔儿 阅读(480) 评论(0) 推荐(0) 编辑
摘要:没有请求头headers时就会这样报错,例如: 阅读全文
posted @ 2019-05-02 09:58 乔儿 阅读(666) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示