In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-11-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article shows you how Python crawls a short video on a certain platform, which is concise and easy to understand, and can definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Basic development environment
Python 3.6
Pycharm
The use of related modules import osimport requests
Install Python and add it to the environment variable, and pip installs the relevant modules you need.
First, determine the demand
Crawl the video content of the funny section.
Second, website data analysis
First of all, we need to make it clear that the loading mode of a good-looking video website is lazy, and you need to slide down the page to load new content.
The loaded content contains the audio playback address and title.
The content is relatively simple, just look at the code.
Import osimport requestsurl = 'https://haokan.baidu.com/videoui/api/videorec?tab=gaoxiao&act=pcFeed&pd=pc&num=20&shuaxin_id=1612592171486'headers = {' user-agent': 'Mozilla/5.0 (Windows NT 10.0 WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'} response = requests.get (url=url, headers=headers) json_data = response.json () videos = json_data ['data'] [' response'] ['videos'] for index in videos: title = index [' title'] play_url = index ['play_url'] video_content = requests.get (url=play_url Headers=headers) .content path = 'video\\' if not os.path.exists (path): os.mkdir (path) with open (path + title + '.mp4', mode='wb') as f: f.write (video_content) print ('saving:', title)
The above content is how Python crawls short videos on a certain platform. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.