用wget命令的爬虫功能抓取网页到本地文件,然后用grep命令分析文件。
1. 抓取网页到本地
选择一个网页,比如 http://www.oschina.net/code/snippet_1391852_26067,用wget抓取到本地。
$ wget http://www.oschina.net/code/snippet_1391852_26067
--2016-10-04 00:20:48-- http://www.oschina.net/code/snippet_1391852_26067
Resolving www.oschina.net (www.oschina.net)... 60.174.156.100
Connecting to www.oschina.net (www.oschina.net)|60.174.156.100|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘snippet_1391852_26067’
snippet_1391852_260 [ <=> ] 44.19K --.-KB/s in 0.1s
2016-10-04 00:20:49 (314 KB/s) - ‘snippet_1391852_26067’ saved [45251]
查看:
$ ls
snippet_1391852_26067
已经抓取到本地。
1. 抓取网页到本地
选择一个网页,比如 http://www.oschina.net/code/snippet_1391852_26067,用wget抓取到本地。
$ wget http://www.oschina.net/code/snippet_1391852_26067
--2016-10-04 00:20:48-- http://www.oschina.net/code/snippet_1391852_26067
Resolving www.oschina.net (www.oschina.net)... 60.174.156.100
Connecting to www.oschina.net (www.oschina.net)|60.174.156.100|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘snippet_1391852_26067’
snippet_1391852_260 [ <=> ] 44.19K --.-KB/s in 0.1s
2016-10-04 00:20:49 (314 KB/s) - ‘snippet_1391852_26067’ saved [45251]
查看:
$ ls
snippet_1391852_26067
已经抓取到本地。