随笔分类 - 爬虫基础
1
摘要:原始代码 错误如图 修改原始代码 成功运行!!!!!!
阅读全文
摘要:crawlspider 使用scrapy genspider -t crawl 文件名字 网址 crawlspider是什么? 也是一个spider,是Spider的一个子类,所以其功能要比Spider要强大 多的一个功能是:提取链接的功能,根据一定的规则,提取指定的链接 链接提取器 LinkExt
阅读全文
摘要:scrapy : 一个框架,不能实现分布式爬取 scrapy-redis : 基于这个框架开发的一套组件,可以让scrapy实现分布式的爬取 所以需要安装扩展库 : pip install scrapy-redis 首先进入这个网站获取分布式爬虫样本 : https://github.com/rma
阅读全文
摘要:windows redis 启动 redis-server.exe redis.windows.conf 注意:可能会启动不成功 第一步,安装目录下 shift + 鼠标右键 进入终端, 第二步,输入 redis-cli.exe 第三步, 输入shutdown 第四步,exit 第五步,重新启动 r
阅读全文
摘要:启动出问题相关配置请参见:https://blog.csdn.net/jungle_hello/article/details/73889320
阅读全文
摘要:# -*- coding: utf-8 -*-import scrapyimport urllib.request # https://accounts.douban.com/login class DoubanSpider(scrapy.Spider): name = 'douban' allow
阅读全文
摘要:修改代理,需要进入下图文件中 打开,自定义代理类 打开settings.py文件 激活代理中间件
阅读全文
摘要:import urllib.requestfrom bs4 import BeautifulSoupimport reimport timeimport random # 公用方法 class CommanCalss: def __init__(self): self.header={'User-A
阅读全文
摘要:安装: pip install scrapy 安装可能会出现问题,此时需要下载一个依赖包 在 这个网站: https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 下载对应版本,,注意,,python3.6 adm64位对应 pip install 文件
阅读全文
摘要:import threading def run(a): #当前线程 c = threading.current_thread() print('子线程开始',c.name) #创建一个线程 t = threading.Thread( target = run,args=(1,),name='hah
阅读全文
摘要:正则匹配: 规则 单字符: . : 除换行以外所有字符 [] :[aoe] [a-w] 匹配集合中任意一个字符 \d :数字 [0-9] \D : 非数字 \w :数字、字母、下划线、中文 \W : 非\w \s :所有的空白字符 \S : 非空白 数量修饰: * : 任意多次 >=0 + : 至少
阅读全文
摘要:#创建handler,针对于http请求handler = urllib.request.HTTPHandler() #opener就是一个对象,一会发送请求的时候,直接使用opener里面的方法open,不要使用urlopen了opener = urllib.request.build_opene
阅读全文
摘要:import urllib.request import urllib.parseimport urllib.error #异常错误捕获 url = 'https://www.ahvndkmvl.net' try: response = urllib.request.urlopen(url) pri
阅读全文
摘要:import urllib.requestimport urllib.parse url = 'http://fanyi.baidu.com/v2transapi' word = 'meizi' formdata = { 'from' : 'en', 'to' : 'zh', 'query':wor
阅读全文
摘要:import ssl ssl._create_default_https_context = ssl._create_unverified_context 直接导入python自带协议库 ssl,创建即可
阅读全文
摘要:import urllib.requestimport urllib.parse #从终端输入直接获取数据,保存到本地 country = input('请输入国家')url = 'http://www.baidu.com/s?' data = { 'ie':'utf-8', 'wd':countr
阅读全文
摘要:import urllib.parse url='https://www.baidu.com/index' name = 'xiaoming'age = 18sex = 'nan'height = 180 data = { 'name':name, 'age':age, 'sex':sex, 'he
阅读全文
摘要:import urllib.parse 如: url = 'https://www.baidu.com/index?name=xiaoming&age=20' #将标准的url进行编码res = urllib.parse.quote(url) print(res) #结果https%3A//www.
阅读全文
摘要:import urllib.request url = 'http://www.baidu.com/'response = urllib.request.urlopen(url=url) print(response.read().decode()) #默认utf8解码 #直接解码有可能会出现下图错
阅读全文
1

浙公网安备 33010602011771号