初中小學生,剛學python爬蟲,英語特別不好,卡在資料保存這里了,搜視頻教程和文案教程,換了三四個庫,還是走不通,請各位指導下可以嗎?
import requests
import json
import pprint
import openpyxl
headers={'nonce': '145bf187-02d3-4f03-8c54-c4beb8cc0d99',
'origin': 'https://bihu.com',
'referer': 'https://bihu.com/people/1741228189',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'signature': '87d67b83e883d2f46a8bdcf7edd332ade97adac098488b98c4d1a82cbd8291e3',
'timestamp': '1590841113883',
'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4128.3 Safari/537.36',
'uuid':'5d9cc323be36739c6a233324e45a1a3c',
'version': '2.16.0',
}
def gethtml():
html=requests.get(url,headers=headers,verify=False).text
data=https://bbs.csdn.net/topics/json.loads(html)
datas=data['data']
lists=datas['data']
content = list()
for shuju in lists:
content.append(shuju['content'])
#pprint.pprint(content)
for name in content:
pprint.pprint(name['title'])
pprint.pprint(name['income'])
if __name__ == '__main__':
for i in range(1,9):
url= 'https://gw.bihu.com/api/content/author/1741228189/list?type=ARTICLE&pageNum='+str(i)
print (gethtml())
"""最后試的庫
file=openpyxl.Workbook()
sheet=file.active
sheet.title='幣乎爬蟲'
sheet['A1']='文章名稱'
sheet['B1']='收益'
for i in :
print(i)
sheet.append(i)
file.save('幣乎爬123. xlsx')
"""
很簡單的就是提取標題和數字的 ,但是我是卡在保存資料這里了,因為我英語還在小學二年級的水平,有些單詞不太熟悉,邏輯也搞不通,但是光學不寫也不行,寫了又不會,只能來請教各位前輩了。
另外求推薦程式員交流的渠道,自己研究太難了!!!!
uj5u.com熱心網友回復:
謝謝各位前輩,最好能講一下邏輯
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/40187.html
標籤:其他開發語言
