摘要: mkvirtualenv --no-site-packages --python=C:\Python36\python.exe MyCrawler 阅读全文
posted @ 2019-01-12 12:58 st--st 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 编写函数,实现功能:将[1,2,[3,[4,5]],6,[7,]] 转换成[1,2,3,4,5,6,7] [1,2,[3,[4,5]],6,[7,]] 用生成器将其生成[1,2,3,4,5,6,7] 编写代码实现func函数,使其实现以下效果:foo = func(8)print(foo(8)) # 阅读全文
posted @ 2018-10-15 08:47 st--st 阅读(179) 评论(0) 推荐(0) 编辑
摘要: https://segmentfault.com/a/1190000015826749 阅读全文
posted @ 2019-03-07 10:34 st--st 阅读(1010) 评论(0) 推荐(0) 编辑
摘要: 使用模块 fake-useragent https://github.com/hellysmile/fake-useragent 1.安装模块 2.配置 阅读全文
posted @ 2019-02-27 16:47 st--st 阅读(1103) 评论(0) 推荐(0) 编辑
摘要: 如何提高scrapy的爬取效率 增加并发: 默认scrapy开启的并发线程为32个,可以适当进行增加。在settings配置文件中修改CONCURRENT_REQUESTS = 100值为100,并发设置成了为100。 降低日志级别: 在运行scrapy时,会有大量日志信息的输出,为了减少CPU的使 阅读全文
posted @ 2019-02-24 15:20 st--st 阅读(962) 评论(0) 推荐(0) 编辑
摘要: ''' 爬取糗事百科的段子,将内容和连接爬取下来,写入scv 使用技术:多线程,锁,队列,xpath,csv ''' import requests import csv from queue import Queue from lxml import etree import threading class Creeper(threading.Thread): def __ini... 阅读全文
posted @ 2019-02-21 16:46 st--st 阅读(148) 评论(0) 推荐(0) 编辑
摘要: ''' 利用多线程、队列爬取表情包 URL:http://www.bbsnet.com/doutu/page/1 ''' import requests from lxml import etree import os import re from urllib import request from queue import Queue import threading class Pr... 阅读全文
posted @ 2019-02-21 09:53 st--st 阅读(164) 评论(0) 推荐(0) 编辑
摘要: Condition版的生产者和消费者模式 threading.Condition 在没有数据的时候处于阻塞状态,有数据可以使用notify的函数通知等等待状态的线程运作 threading.Condition 实际上是继承threading.Lock acquire:上锁。 release:解锁。 阅读全文
posted @ 2019-02-20 20:38 st--st 阅读(166) 评论(0) 推荐(0) 编辑
摘要: ''' Lock版的生产者和消费者模式 ''' import threading import random import time gMoney = 1000 # 原始金额 gLoad = threading.Lock() gTime = 0 # 生产次数 class Producer(threading.Thread): def run(self... 阅读全文
posted @ 2019-02-20 20:06 st--st 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 一、安装selenium和chromedriver 二、安装PhantomJS 三、介绍 selenium最初是一个测试工具,而爬虫中使用它主要是为了解决requests无法直接执行JavaScript代码的问题 selenium本质是通过驱动浏览器,完全模拟浏览器的操作,比如跳转、输入、点击、下拉 阅读全文
posted @ 2019-01-24 14:26 st--st 阅读(212) 评论(0) 推荐(0) 编辑
摘要: Beautiful Soup提供一些简单的、python式的函数用来处理导航、搜索、修改分析树等功能。它是一个工具箱,通过解析文档为用户提供需要抓取的数据,因为简单,所以不需要多少代码就可以写出一个完整的应用程序。 一、安装 二、使用 三、遍历文档树 获取标签的文本 tag对象 四、五种过滤器 fi 阅读全文
posted @ 2019-01-24 10:37 st--st 阅读(182) 评论(0) 推荐(0) 编辑
摘要: 使用Xpath模块 def get_page(url): import requests headers = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) 阅读全文
posted @ 2019-01-23 11:03 st--st 阅读(424) 评论(0) 推荐(0) 编辑