In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to use python to crawl and download bilibili video, for this problem, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
Bilibili is popular because of the coexistence of interest and knowledge. As the saying "you watch in bilibili, I study in bilibili", bilibili still has some good quality learning videos. What should you do when you see your favorite video on bilibili and want to save it?
To get to the point, this tweet mainly introduces how to download the favorite videos from bilibili to help more partners who need to learn. the detailed steps are as follows: the web page analyzes the results of video download methods to show the addition of Wechat video numbers. once again ignited the field of short videos, today we crawled bilibili's daily largest number of small videos, other types of videos can refer to this method.
Video download method
The web page has been analyzed in the previous section, and now we can use the requests.get method to get the short video on bilibili.
Core code
Def get_json (url): headers = {'User-Agent':' Mozilla/5.0 (X11) Linux x86x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'} params= {'page_size': 10,' next_offset': str (num), 'tag':' Hot Today', 'platform':' pc'} try: html = requests.get (url, params=params, headers=headers) return html.json () except BaseException: print ('request error') pass def download (url) Path): start = time.time () # start time size = 0 headers = {'User-Agent':' Mozilla/5.0 (X11) Linux x86 / 64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36'} response = requests.get (url,headers=headers,stream=True) chunk_size= 1024 content_size = int (response.headers ['content-length']) if response.status_code = 200: with open (path,'wb') as file: for data in response.iter_content (chunk_size=chunk_size): file.write (data) size + = len (data)
Achievement presentation
In the previous section, we have shown how to download videos with Python. Let's show the results below.
This is the answer to the question about how to use python to crawl and download bilibili video. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.