Skip to content

Commit db2f9a3

Browse files
committed
tieba
1 parent e10b02c commit db2f9a3

File tree

7 files changed

+28
-26
lines changed

7 files changed

+28
-26
lines changed

0-Spider/tiebaSpider/README.md

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1 @@
1-
# 项目说明
2-
3-
该项目为爬取指定贴吧的前三页帖子的发帖用户和回帖用户的用户名
4-
5-
data 目录为存放数据的目录,其中以天为单位创建二级目录,以贴吧名为三级单位存储抓取结果
6-
7-
目录结构类似于:
8-
9-
data
10-
11-
--20170626
12-
13-
-----戒赌吧.txt
14-
15-
-----网易吧.txt
16-
17-
tiebaname 目录为存放贴吧名字的目录,将要爬取的贴吧名字写入该目录下的name.txt文件中
18-
19-
目录结构类似于:
20-
21-
tiebaname
22-
23-
--name.txt
24-
25-
采用的是python 的beautifulSoup库,效果不太理想,但后续会逐步改善,可能换成别的框架
1+
这两个文件夹下的爬虫都是为了实现爬取贴吧前三页帖子的发帖人和回帖人,spider1使用的是BeautifulSoup+urllib2,spider2使用的是scrapy
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 项目说明
2+
3+
该项目为爬取指定贴吧的前三页帖子的发帖用户和回帖用户的用户名
4+
5+
data 目录为存放数据的目录,其中以天为单位创建二级目录,以贴吧名为三级单位存储抓取结果
6+
7+
目录结构类似于:
8+
9+
data
10+
11+
--20170626
12+
13+
-----戒赌吧.txt
14+
15+
-----网易吧.txt
16+
17+
tiebaname 目录为存放贴吧名字的目录,将要爬取的贴吧名字写入该目录下的name.txt文件中
18+
19+
目录结构类似于:
20+
21+
tiebaname
22+
23+
--name.txt
24+
25+
采用的是python 的beautifulSoup库,效果不太理想,但后续会逐步改善,可能换成别的框架
File renamed without changes.
File renamed without changes.
File renamed without changes.

0-Spider/tiebaSpider/spider2/tieba/tieba/spiders/tieba1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import urllib
55
import time
66

7+
78
class TiebaSpider(scrapy.Spider):
89

910
name = 'tieba'
@@ -34,5 +35,5 @@ def parse(self, response):
3435
fw = open("data/%s_all_href.txt" % time.strftime('%Y%m%d'), "a")
3536
for ahref in ahref_list:
3637
href = "https://tieba.baidu.com" + ahref
37-
fw.write(href+"\n")
38+
fw.write(href + "\n")
3839
fw.close()

0 commit comments

Comments
 (0)