摘要: 这是循环请求10次页面。总时间大概是10秒左右,如果是普通的循环请求10次页面而不添加异步的话,时间大概在30秒以上,当然这个数据可能有误,因为有网速的问题存在,但大体的效果应该是不变的。 import aiohttp from bs4 import BeautifulSoup import asyncio import time async def html_list(url,h... 阅读全文
posted @ 2018-07-17 10:34 python赵小弟 阅读(723) 评论(0) 推荐(0) 编辑
摘要: 对于异步框架而言,这些延迟是无法接受的。因此, Twisted 提供了 twisted.enterprise.adbapi, 遵循DB-API 2.0协议的一个异步封装。adbapi 在单独的线程里面进行阻塞数据库操作, 当操作完成的时候仍然通过这个线程来进行回调。同事,原始线程能继续进行正常的工作 阅读全文
posted @ 2018-07-07 09:51 python赵小弟 阅读(3218) 评论(0) 推荐(0) 编辑
摘要: http://jiyan.c2567.com/index.html 阅读全文
posted @ 2018-05-15 10:31 python赵小弟 阅读(7005) 评论(0) 推荐(0) 编辑
摘要: # 导入必备的包 # 本文爬取的是顶点小说中的完美世界为列。文中的aa.text,bb.text为自己创建的text文件 import requests from bs4 import BeautifulSoup # 爬取目标url url = 'https://www.x23us.com/html/42/42377/' headers = { 'User-Agent': 'Mozi... 阅读全文
posted @ 2018-04-28 14:27 python赵小弟 阅读(1597) 评论(1) 推荐(0) 编辑
摘要: import pandas as pd import os os.chdir(u'E:\内网通得东西\练习4') #参数初始化 filename = 'bankloan.xls' data = pd.read_excel(filename) x = data.iloc[:,:8].as_matrix() y = data.iloc[:,8].as_matrix() from sklearn.... 阅读全文
posted @ 2018-04-21 09:27 python赵小弟 阅读(1820) 评论(0) 推荐(0) 编辑
摘要: import os import pandas as pd from sklearn.cross_validation import train_test_split from sklearn import tree from sklearn import metrics infile = 'sales_data.xls' os.chdir('E:\pycharm\machine learni... 阅读全文
posted @ 2018-04-21 09:26 python赵小弟 阅读(153) 评论(0) 推荐(0) 编辑
摘要: #encoding=utf-8 from __future__ import unicode_literals import sys sys.path.append("../") import jieba import jieba.posseg import jieba.analyse print('='*40) print('1. 分词') print('-'*40) seg_list ... 阅读全文
posted @ 2018-04-21 09:21 python赵小弟 阅读(243) 评论(0) 推荐(0) 编辑
摘要: from sklearn import datasets import pandas as pd import numpy as np from sklearn.cross_validation import train_test_split from sklearn.preprocessing import StandardScaler from sklearn.linear_model im... 阅读全文
posted @ 2018-04-21 09:18 python赵小弟 阅读(1988) 评论(0) 推荐(0) 编辑
摘要: 上面的为最终结果import requests import re import xlwt import json # 导入必须的包: xlwt,json,requests,re. headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Ch... 阅读全文
posted @ 2018-04-16 20:35 python赵小弟 阅读(5836) 评论(0) 推荐(1) 编辑