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('', response.text)[0]print(pprint.pprint(html_data))json_data = json.loads(html_data)# print(pprint.pprint(json_data))
get_video_info(url)