5 pandas報存數據
with open 方法
for 循環寫入 點write
一譯中文官方文檔:http://python.usyiyi.cn/
爬取《小王子》豆瓣短評的數據,並把數據保存爲本地的excel表格
import requests
from lxml import etree
url = 'https://book.douban.com/subject/1084336/comments/'
r = requests.get(url).text
s = etree.HTML(r)
file = s.xpath('//div[@class="comment"]/p/text()')
import pandas as pd
df = pd.DataFrame(file)
df.to_excel('pinglun.xlsx')
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
【Python爬蟲】基本原理和框架
Mercy92
2020-07-08 10:40:50
【Python 爬蟲】使用友盟API獲取數據
Mercy92
2020-07-08 10:40:48
【Python 爬蟲】使用新榜API獲取數據
Mercy92
2020-07-08 10:40:48
Python爬蟲之selenium爬取英雄聯盟官網英雄皮膚圖片下載到本地和保存到數據庫
xyl180808
2020-07-08 00:23:55
python爬蟲:番號挖掘機!可下載直接運行。
你就叫我李大帅
2020-07-07 21:45:58
使用Beautifulsoup解析網頁遇到的問題
李孟笛
2020-07-07 18:21:30
python如何下載MP4視頻和獲取時長
公众号菜鸟童靴
2020-07-07 11:53:23
execjs執行js代碼報錯:Exception in thread Thread-1
公众号菜鸟童靴
2020-07-07 11:53:23
Python爬蟲精簡步驟 HTML基礎(上)
Lora鳃鳃
2020-07-07 11:50:32
一個簡單的校園網登錄程序 || 爬蟲+tkinter
阿腾木
2020-07-07 06:57:17
python爬蟲初學的小記錄
weixin_42929804
2020-07-07 03:33:36
五、分佈式爬蟲學習之BeautSoup4
Mr_Little_li
2020-07-06 17:47:01
十三、學習分佈式爬蟲之字體反爬
Mr_Little_li
2020-07-06 17:47:01
八、學習分佈式爬蟲之多線程
Mr_Little_li
2020-07-06 17:47:01