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('当前页面爬取完成') 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爬虫的经过与心得。 同时也是为了分享一下如何能更高效率的学习写爬虫。

AltStyle によって変換されたページ (->オリジナル) /