python获取b站视频选集目录名
import requestsimport re
import json
def fin_data(_url):
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
}
try:
get_url = requests.get(url=_url, headers=headers)
get_url.raise_for_status()
return get_url.text
except requests.RequestException as e:
print(f"请求失败: {e}")
return None
def extract_and_process_content(content):
# 使用正则表达式提取部分内容
pattern = re.compile(r'"part":"([^"]+)"')
matches = pattern.findall(content)
def decode_unicode(text):
return json.loads('"' + text + '"')
# 打印提取的并转换后的内容
for match in matches:
decoded_content = decode_unicode(match)
print(decoded_content)
if __name__ == '__main__':
url = 'https://www.bilibili.com/video/BV1uw411j7wh'# 替换为实际的网页链接
webpage_content = fin_data(url)
if webpage_content:
extract_and_process_content(webpage_content)
哇塞,谢谢分享!学习到了! 学习到了,这个很有用,感谢分享 楼主有点东西的,学习到了 刚好在学习python,感谢 刚好需要,感谢楼主 楼主大佬{:1_921:} 这代码学到了
页:
[1]