羁绊的小水门 2022-07-23 12:09 采纳率: 20%
浏览 311
已结题

Python爬虫时遇到问题: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Python爬虫时遇到问题:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
我将源码发给大家,请大家帮忙解决!
import requests
import re
import json
import pprint

url = 'https://www.bilibili.com/video/BV13Q4y1N734?spm_id_from=333.337.search-card.all.click%27

def get_video(url):
headers = {
'referer': 'https://www.bilibili.com/',
'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.62'
}
response = requests.get(url=url, headers=headers)
return response

def get_video_info(url):
response = get_video(url)
print(response)
title = '【AMV-柯南】全员高燃混剪,你准备好了吗'
# print(response)

html_data = re.findall('<script>window.__playinfo__(.*?)</script>', response.text)[0]
print(pprint.pprint(html_data))
json_data = json.loads(html_data)

# print(pprint.pprint(json_data))

get_video_info(url)

  • 写回答

3条回答 默认 最新

  • 亖夕 Python领域新星创作者 2022-07-23 12:50
    关注

    img

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 8月3日
  • 已采纳回答 7月26日
  • 创建了问题 7月23日

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?