From 790b980005d3e9d1ece58f9668ba1638ff3a1b8a Mon Sep 17 00:00:00 2001 From: Zhao Shulin <43167791+shulincome@users.noreply.github.com> Date: Thu, 14 Nov 2019 15:26:56 +0800 Subject: [PATCH 1/2] Update baidutieba.py --- .../baidutieba.py" | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git "a/Beautiful Soup \347\210\254\350\231\253/baidutieba.py" "b/Beautiful Soup \347\210\254\350\231\253/baidutieba.py" index 40989f5..7805358 100644 --- "a/Beautiful Soup \347\210\254\350\231\253/baidutieba.py" +++ "b/Beautiful Soup \347\210\254\350\231\253/baidutieba.py" @@ -49,14 +49,7 @@ def get_content(url): # 开始筛选信息,并保存到字典中 comment['title'] = li.find( 'a', attrs={'class': 'j_th_tit '}).text.strip() - comment['link'] = "http://tieba.baidu.com/" + \ - li.find('a', attrs={'class': 'j_th_tit '})['href'] - comment['name'] = li.find( - 'span', attrs={'class': 'tb_icon_author '}).text.strip() - comment['time'] = li.find( - 'span', attrs={'class': 'pull-right is_show_create_time'}).text.strip() - comment['replyNum'] = li.find( - 'span', attrs={'class': 'threadlist_rep_num center_text'}).text.strip() + comment['last_reply_data'] = li.find('span',attrs={'class':'threadlist_reply_date pull_right j_reply_data'}).text.strip() comments.append(comment) except: print('出了点小问题') @@ -73,7 +66,7 @@ def Out2File(dict): with open('TTBT.txt', 'a+') as f: for comment in dict: f.write('标题: {} \t 链接:{} \t 发帖人:{} \t 发帖时间:{} \t 回复数量: {} \n'.format( - comment['title'], comment['link'], comment['name'], comment['time'], comment['replyNum'])) + comment['title'], comment['last_reply_data'])) print('当前页面爬取完成') From e89ef774653965c6b045a2c4fd101846ee8c62ef Mon Sep 17 00:00:00 2001 From: Ehco Date: Tue, 26 Nov 2019 14:51:23 +0800 Subject: [PATCH 2/2] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 6a27328..c359403 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ # Python-crawler +> 由于代码是比较早之前写的,抓取的网站目录结构可能有所变动 +> 所以部分代码可能不能使用了,欢迎正在学习爬虫的大家给这个项目**提PR** +> 让更多的代码能跑起来~ + 从零开始系统化的学习写Python爬虫。 主要是记录一下自己写Python爬虫的经过与心得。 同时也是为了分享一下如何能更高效率的学习写爬虫。