I encountered a problem with the Python crawler:
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I will send you the source code, please help to solve it!
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 (WindowsNT 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-Conan】The whole crew is high-firing and mixed, are you ready?'
# 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)