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