Skip to content

Commit e2c1ab7

Browse files
committed
update readme
1 parent c985586 commit e2c1ab7

3 files changed

Lines changed: 69 additions & 47 deletions

File tree

README.md

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,2 @@
1-
#Python 爬虫:把廖雪峰的教程转换成 PDF 电子书
2-
3-
### 系统要求
4-
python3.4以上版本, 不支持python2.x
5-
6-
7-
### 准备工具
8-
9-
requests、beautifulsoup 是爬虫两大神器,reuqests 用于网络请求,beautifusoup 用于操作 html 数据。有了这两把梭子,干起活来利索。scrapy 这样的爬虫框架我们就不用了,这样的小程序派上它有点杀鸡用牛刀的意思。此外,既然是把 html 文件转为 pdf,那么也要有相应的库支持, wkhtmltopdf 就是一个非常的工具,它可以用适用于多平台的 html 到 pdf 的转换,pdfkit 是 wkhtmltopdf 的Python封装包。首先安装好下面的依赖包
10-
11-
```python
12-
pip install requests
13-
pip install beautifulsoup4
14-
pip install pdfkit
15-
```
16-
17-
### 安装 wkhtmltopdf
18-
Windows平台直接在 [http://wkhtmltopdf.org/downloads.html](http://wkhtmltopdf.org/downloads.html) 下载稳定版的 wkhtmltopdf 进行安装,安装完成之后把该程序的执行路径加入到系统环境 $PATH 变量中,否则 pdfkit 找不到 wkhtmltopdf 就出现错误 “No wkhtmltopdf executable found”。Ubuntu 和 CentOS 可以直接用命令行进行安装
19-
20-
```shell
21-
$ sudo apt-get install wkhtmltopdf # ubuntu
22-
$ sudo yum intsall wkhtmltopdf # centos
23-
```
24-
25-
### 运行
26-
```python
27-
python crawler.py
28-
```
29-
30-
### 效果图
31-
![image](./crawer-pdf.png)
32-
33-
### 常见问题
34-
35-
1. SyntaxError: Missing parentheses in call to 'print'
36-
37-
beautifulsoup3不支持python2,所以下载beautifulsoup是要指定 beautifusoup4
38-
2. 如果是使用PyCharm开发, 那么运行的时候要在shell/cmd 窗口执行脚本, 直接在Pycharm中运行会找不到 wkhtmltopdf命令
39-
40-
41-
### contact me
42-
43-
>作者:liuzhijun
44-
>微信号: lzjun567
45-
>公众号:一个程序员的微站(VTtalk)
46-
47-
1+
* [Python 爬虫:把廖雪峰的教程转换成 PDF 电子书](./pdf/README.md)
2+
* [用Python 写“爱心”](./heart/README.md)

heart/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
### 准备工作
2+
大体思路就是把微博数据爬下来,数据经过清洗加工后再分词处理,处理后的数据交给词云工具,配合科学计算工具和绘图工具制作成图像出来,涉及到的工具包有:
3+
4+
Requests 用于网络请求爬取微博数据,结巴分词 jieba 进行中文分词处理,wordcloud 词云处理,图片处理库 Pillow,科学计算工具 NumPy ,类似于 MATLAB 的 2D 绘图库 Matplotlib
5+
6+
### 工具安装
7+
安装这些工具包时,不同系统平台有可能出现不一样的错误,wordcloud,requests,jieba 都可以通过普通的 pip 方式在线安装,
8+
```python
9+
pip install wordcloud
10+
pip install requests
11+
pip install jieba
12+
```
13+
在Windows 平台安装 Pillow,NumPy,Matplotlib 直接用 pip 在线安装会出现各种问题,比较推荐的一种方式是在一个叫 Python Extension Packages for Windows [1] 的第三方平台下载 相应的.whl 文件安装。可以根据自己的系统环境选择下载安装 cp27 对应 python2.7,amd64 对应 64 位系统。下载到本地后进行安装
14+
```python
15+
pip install Pillow-4.0.0-cp27-cp27m-win_amd64.whl
16+
pip install scipy-0.18.0-cp27-cp27m-win_amd64.whl
17+
pip install numpy-1.11.3+mkl-cp27-cp27m-win_amd64.whl
18+
pip install matplotlib-1.5.3-cp27-cp27m-win_amd64.whl
19+
```
20+
其他平台可根据错误提示 Google 解决。

pdf/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#Python 爬虫:把廖雪峰的教程转换成 PDF 电子书
2+
3+
### 系统要求
4+
python3.4以上版本, 不支持python2.x
5+
6+
7+
### 准备工具
8+
9+
requests、beautifulsoup 是爬虫两大神器,reuqests 用于网络请求,beautifusoup 用于操作 html 数据。有了这两把梭子,干起活来利索。scrapy 这样的爬虫框架我们就不用了,这样的小程序派上它有点杀鸡用牛刀的意思。此外,既然是把 html 文件转为 pdf,那么也要有相应的库支持, wkhtmltopdf 就是一个非常的工具,它可以用适用于多平台的 html 到 pdf 的转换,pdfkit 是 wkhtmltopdf 的Python封装包。首先安装好下面的依赖包
10+
11+
```python
12+
pip install requests
13+
pip install beautifulsoup4
14+
pip install pdfkit
15+
```
16+
17+
### 安装 wkhtmltopdf
18+
Windows平台直接在 [http://wkhtmltopdf.org/downloads.html](http://wkhtmltopdf.org/downloads.html) 下载稳定版的 wkhtmltopdf 进行安装,安装完成之后把该程序的执行路径加入到系统环境 $PATH 变量中,否则 pdfkit 找不到 wkhtmltopdf 就出现错误 “No wkhtmltopdf executable found”。Ubuntu 和 CentOS 可以直接用命令行进行安装
19+
20+
```shell
21+
$ sudo apt-get install wkhtmltopdf # ubuntu
22+
$ sudo yum intsall wkhtmltopdf # centos
23+
```
24+
25+
### 运行
26+
```python
27+
python crawler.py
28+
```
29+
30+
### 效果图
31+
![image](./crawer-pdf.png)
32+
33+
### 常见问题
34+
35+
1. SyntaxError: Missing parentheses in call to 'print'
36+
37+
beautifulsoup3不支持python2,所以下载beautifulsoup是要指定 beautifusoup4
38+
2. 如果是使用PyCharm开发, 那么运行的时候要在shell/cmd 窗口执行脚本, 直接在Pycharm中运行会找不到 wkhtmltopdf命令
39+
40+
41+
### contact me
42+
43+
>作者:liuzhijun
44+
>微信号: lzjun567
45+
>公众号:一个程序员的微站(VTtalk)
46+
47+

0 commit comments

Comments
 (0)