|
|

楼主 |
发表于 2018-4-19 17:29:46
|
显示全部楼层
这是爬取评论- import requests
- from bs4 import BeautifulSoup
- import re
- html=requests.get('http://comment.kuwo.cn/com.s?type=get_rec_comment&uid=0&prod=newWeb&digest=15&sid=5899379&page=1&'
- 'rows=10&f=web&gid=46fff5dd-5782-4eed-bc64-ddc5ed74d485&jpcallback=getRecCommentListFn&_=15241'
- '27007154').text
- html=re.search(r'try(.+)',html).group(1)
- html=re.search(r'{var jsondata=(.+)',html).group(1)
- name=html['rows']
- with open('text3.txt','w',encoding='utf-8') as f:
- for each in name:
- f.write([each['msg']])
复制代码
但是会爆TypeError: string indices must be integers这个错误,这个好像是get型json数据,请问各位鱼油大佬,这个评论该怎么提取 |
|