Home > other >  [for] Python barrage of some art video website
[for] Python barrage of some art video website

Time:10-11

CSDN fellow leaders, there is something wrong with the Python small white want to consultation, the following code, where there is a problem, I should be how to change, to correctly parse barrage site, your answers will be great help for me!
 
The from bs4 import BeautifulSoup

The import re
The import requests

The import xlsxwriter

Def getcomments () :
Headers={the user-agent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.26 Safari 537.36/Core/1.63.5558.400 QQBrowser/10.1.1695.400}
"Url="https://cmts.iqiyi.com/bullet/30/00/7564083000_300_1.z? Rn=0.21263356332144867 & amp; Business=danmu& Is_iqiyi=true& Is_video_page=true& Tvid=7564083000 & amp; Albumid=233592301 & amp; Categoryid=2 & amp; Qypid=01010021010000000000
"HTML=requests. Get (url, headers=headers)
bullets_data=https://bbs.csdn.net/topics/html.content
Bullets=decompress (bullets_data)
Danmu=bullets. Decode (" utf-8 ", "ignore")
Soup=BeautifulSoup (danmu, "LXML")
Workbook=xlsxwriter. Workbook (file_excel)
Sheet=workbook. Add_worksheet (' barrage file ')
Bold=workbook. Add_format ({" bold ": True})
Sheet. Write (A1, u 'body', bold)
Sheet. Write (I1, u 'time', bold)
Sheet. Write (' L1 'u' blues', bold)
BulletInfo=soup. Select (' bulletInfo ')
The row=2
For x in bulletInfo:
The content=x.c ontent. Text
Name="world owes me a first love"
Times=x.s howtime. Text
Time=STR (int (eval (times)/60)) + "points" + STR (eval (times) - the int (eval (times)/60 * 60) + "seconds" # points hexadecimal data format into the eval function transformation calculation
Sheet. Write (' A % d % row, content)
Sheet. Write (' I % d % row, time)
Sheet. Write (' L % d % row, name)
The row +=1
Workbook. The close ()
If __name__=="__main__ ':
File_excel="E: \ Study " - 1. XLSX "
Getcomments ()
Print (" I finished ")


Looking forward to, every answer, thanks again!

CodePudding user response:

No big help me to answer it? A decompress function seems to lack, who will write

CodePudding user response:

A wave, to communication,
  • Related