摘要: "菜鸟教程" 阅读全文
posted @ 2017-08-11 10:43 岑忠满 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 连接方法 使用 Python DB API(整合了绝大部分的数据库) 使用 pymysql 包 整体思想 数据库连接对象 connection 数据库游标对象 cursor 程序Demo import pymysql.cursors class MySQLUtils(): def executeSQ 阅读全文
posted @ 2017-08-11 10:27 岑忠满 阅读(409) 评论(0) 推荐(0) 编辑
摘要: 整体架构 "主函数" 一、 URL管理器 管理即将爬取的URL和已经爬取的URL "URL管理器" 二、 网页下载器 用于下载网页 "三种urllib实现网页下载,含cookie模拟登陆" 三、 网页解析器 用于解析网页,获得有价值数据或者新的待爬取URL填充URL管理器 "使用bs4的网页解析器" 阅读全文
posted @ 2017-08-11 10:17 岑忠满 阅读(513) 评论(0) 推荐(0) 编辑
摘要: coding=UTF 8 HTML输出器 import sys class htmlOutputer(): def __init__(self): self.data = [] def collect_data(self, data): if data is None: return self.da 阅读全文
posted @ 2017-08-11 10:16 岑忠满 阅读(192) 评论(0) 推荐(0) 编辑
摘要: coding=UTF 8 HTML解释器 import re from bs4 import BeautifulSoup class htmlParser(): def parse(self, url, html_cont): if url is None or html_cont is None: 阅读全文
posted @ 2017-08-11 10:14 岑忠满 阅读(288) 评论(0) 推荐(0) 编辑
摘要: coding=UTF 8 import re import urllib.request, http.cookiejar, urllib.parse print(' 第一种方法 ') URL = 'https://baike.baidu.com/item/%E5%B7%B4%E6%B2%99%E5% 阅读全文
posted @ 2017-08-11 10:13 岑忠满 阅读(340) 评论(0) 推荐(0) 编辑
摘要: coding=UTF 8 url管理器 class urlManeger: def __init__(self): self.new_urls = set() self.old_urls = set() def add_new_url(self, url): if url is None: retu 阅读全文
posted @ 2017-08-11 10:10 岑忠满 阅读(144) 评论(0) 推荐(0) 编辑
摘要: coding=UTF 8 import html_download import html_outputer import html_parser import url_maneger class SpiderMain(object): 构造器 def __init__(self): 1:初始化组件 阅读全文
posted @ 2017-08-11 10:08 岑忠满 阅读(356) 评论(0) 推荐(0) 编辑