08 2016 档案
摘要:"useragentstring.com" 网站几乎廊括了所有的User Agent,刚学了scrapy,打算那它练手,把上面的 user agent 爬取下来。 本文只爬取常见的 FireFox, Chrome, Opera, Safri, Internet Explorer 一、创建爬虫项目 1
阅读全文
摘要:```python
headers = [ {"User-Agent": "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"}, {"User-Agent": "Mozilla/4.0 (compatible; MSIE 7.0...
阅读全文
摘要:说明 : 本文参考了官网文档,以及stackoverflow的几个问题 注意 : 下面这个爬虫不能实际运行!我只是用它来展示登录,以及之后如何处理。 方式一:FormRequest 方式二:FormRequest.from_response
阅读全文
摘要:说明 : 本文参照了官网文档,以及stackoverflow的几个问题 概要 : 在scrapy中使用代理,有两种使用方式 1. 使用中间件 2. 直接设置Request类的meta参数 方式一:使用中间件 要进行下面两步操作 1. 在文件 settings.py 中激活代理中间件 2. 在文件 m
阅读全文
摘要:说明 : 本文参照了 "官网" 的 dmoz 爬虫例子。 不过这个例子有些年头了,而 dmoz.org 的网页结构已经不同以前。 所以我对 也相应地进行了修改 。 概要 : 本文提出了scrapy 的三个入门应用场景 1. 爬取单页 2. 根据目录页面,爬取所有指向的页面 3. 爬取第一页,然后根据
阅读全文
摘要:网页结构 : 连接 : Play : 注意 与`css`两种方式的区别与联系
阅读全文
摘要:```python
import numpy as np
import pandas as pd df = pd.DataFrame(np.random.randint(0,100,100), columns=['score']) # 以所在区间作为标签。如 x=5,返回:'[0-10]'
def make_label(x, step=10): m = x // step re...
阅读全文
摘要:问题 : 有一个DataFrame,列名为: 现需要改为: 有何办法? 解决 : 方式一:columns属性 方式二:rename方法、columns参数
阅读全文
摘要:说明 之前在 window 10 (64) + python 3.5 (64) 环境下就已经成功安装了 scrapy ,当然也费了不少周折。 由于近日将系统换回 windows 7 (64),再安装 scrapy 时又遇到了一些问题,不过折腾了十来分钟后,还是成功了。 为了方便后来的朋友,特将 py
阅读全文
摘要:说明:此文的第一部分参考了 "这里" 用python进行线性回归分析非常方便,有现成的库可以使用比如: "例子" 、 "例子" 、 "例子" 等。 不过本文使用 库的 , 支持任意维度 ,非常好用。 一、二维直线的例子 预备知识 :线性方程 表示平面一直线 下面的例子中,我
阅读全文
摘要:找到一个递归神经网络的例子,没看懂。 先保存,慢慢看。 "原文"
阅读全文
摘要:问题描述 用python写爬虫,很多时候我们会先在cmd下先进行尝试。 运行爬虫之后,肯定的,我们想看看爬取的结果。 于是,我们print... 运气好的话,一切顺利。但这样的次数不多,更多地,我们会遇到这样的错误: UnicodeEncodeError: 'gbk' codec can't enc
阅读全文
摘要:Mini project description Rock paper scissors lizard Spock Rock paper scissors is a hand game that is played by two people. The players count to three
阅读全文
摘要:How to check out "codeskulptor" 's host? Use tool: "namecheckup" Append to your hosts file, path:
阅读全文
摘要:```python #Practice Exercises for Logic and Conditionals # Solve each of the practice exercises below. # 1.Write a Python function is_even that takes as input the parameter number (an integer) and ...
阅读全文
摘要:```python
# Practice Exercises for Functions # Solve each of the practice exercises below. # 1.Write a Python function miles_to_feet that takes a parameter miles and # returns the number of feet ...
阅读全文
摘要:1、配置文件 如果使用mysql的默认配置,在使用的过程中会出现很多问题,如汉字是乱码等。 在mysql的根目录(如:D:\mysql\mysql 5.7.14 winx64\)下,新建配置文件my.ini(utf 8编码): 2、安装mysql服务 管理员身份启动cmd 3、启动mysql服务 如
阅读全文
摘要:不使用 pythonic 的循环: 函数调用返回一个以上的变量类型 循环永不终止 python example: i = 0 while i
阅读全文