随笔分类 -  python

python3+scrapy 趣头条爬虫实例
摘要:项目简介 爬取趣头条新闻(http://home.qutoutiao.net/pages/home.html),具体内容: 1、列表页(json):标题,简介、封面图、来源、发布时间 2、详情页(html):详细内容和图片目录结构 生成的数据文件-单条... 阅读全文
posted @ 2018-02-16 15:21 fonyer 阅读(851) 评论(0) 推荐(0)
python爬虫之scrapy
摘要:环境:centos6 + python3安装:pip3 install scrapy报错:src/twisted/test/raiser.c:4:20: error: Python.h: No such file or directory src... 阅读全文
posted @ 2018-02-11 04:27 fonyer 阅读(243) 评论(0) 推荐(0)
python爬虫之urllib
摘要:#coding=utf-8 #urllib操作类 import timeimport urllib.requestimport urllib.parsefrom urllib.error import HTTPError, URLErrorim... 阅读全文
posted @ 2018-02-05 01:42 fonyer 阅读(206) 评论(0) 推荐(0)
python 数据库操作类
摘要:#安装PyMySQL:pip3 install PyMySQL #!/usr/bin/python3 #coding=utf-8 #数据库操作类 from datetime import * import pymysql import... 阅读全文
posted @ 2018-02-02 03:55 fonyer 阅读(291) 评论(0) 推荐(0)
python mysql
摘要:写操作:#安装PyMySQL:pip3 install PyMySQL#!/usr/bin/python3#coding=utf-8 import pymysql # 打开数据库连接db = pymysql.connect("localhost","r... 阅读全文
posted @ 2018-02-01 00:52 fonyer 阅读(127) 评论(0) 推荐(0)
python 协程
摘要:协程之yield#coding=utf-8import timedef A(): while True: print('---A---') yield ... 阅读全文
posted @ 2018-01-26 00:11 fonyer 阅读(116) 评论(0) 推荐(0)
python socket编程
摘要:UDP协议:#coding=utf-8from threading import Threadfrom socket import *#收数据def receiveData(udpSocket,destIp,destPort): whil... 阅读全文
posted @ 2018-01-20 03:35 fonyer 阅读(207) 评论(0) 推荐(0)
python 线程
摘要:1、线程类import threading import time class MyThread(threading.Thread): """docstring for MyThread""" def run(self): for x in range(2): ... 阅读全文
posted @ 2018-01-11 23:15 fonyer 阅读(127) 评论(0) 推荐(0)
多进程copy文件
摘要:from multiprocessing import Pool,Manager import os,time def copyFileTask(fileName,oldFolderName,newFolderName,queue): fr = open(old... 阅读全文
posted @ 2018-01-10 02:27 fonyer 阅读(245) 评论(0) 推荐(0)
python消息队列Queue
摘要:实例1:消息队列Queue,不要将文件命名为“queue.py”,否则会报异常“ImportError: cannot import name 'Queue'”#coding=utf-8from multiprocessing import Queue q = Qu... 阅读全文
posted @ 2018-01-10 02:22 fonyer 阅读(1068) 评论(0) 推荐(0)
python 进程
摘要:#fork在window下不支持import osimport timeimport sys pid = os.fork()if pid == 0:#子进程 time.sleep(5) print('After 5 seconds') ... 阅读全文
posted @ 2018-01-10 02:17 fonyer 阅读(164) 评论(0) 推荐(0)