what are you having? python I won't answer the related error report 、 Or source code information / Module installation /
Women's clothing bosses are proficient in skillsYou can come here :(https://jq.qq.com/?_wv=1027&k=2Q3YTfym) perhaps +V:python10010 Ask me ( At the end of the article )
python Learning exchange group :903971231###
Massive video data can be saved with one click
html Label data analysis method
re Method of parsing data
python 3.8
pycharm 2021.2
requests >>> pip install requests
parsel >>> pip install parsel
+python Installation package Installation tutorial video
+pycharm Community Edition pro And Activation code free
We do this by putting a link in front of the page + view-source:https:.....
You can view the web page source code , We can find in the web page source code Video link address
1. Send network request
2. get data Web source code
3. Filter data Video details page address
4. Send network request
5. get data Web source code
6. Filter data Video address
7. Access the video playback address
8. Get video binary data
9. preservation Video data
import requests # Send network request
import re # Regular modules
import parsel # Parsing data module
See who hasn't installed the module
url_1 = 'https://www.520mmtv.com/tag/xg.html'
response_1 = requests.get(url_1)
data_html_1 = response_1.text
selector = parsel.Selector(data_html_1)
info_url_list = selector.css('.meta-title::attr(href)').getall()
title_url_list = selector.css('.meta-title::text').getall()
new_title_list = [i for i in title_url_list if i != ' ']
# zip: We need to link the video Loop together with the title
for zip_data in zip(info_url_list, new_title_list):
url = zip_data[0]
# 1. Send network request
response = requests.get(url=url)
# <Response [200]>: Send the request and respond successfully
# 2. get data Web source code
data_html = response.text
# 3. Filter data Video address
# The first parameter matches the rule Second, where do we want to match
video_url = re.findall('url: "(.*?)",', data_html)[0]
print(video_url)
# 4. Access the video playback address
# 5. Get video / Audio / picture binary data
video_data = requests.get(video_url).content
title = zip_data[1]
# 6. preservation Video data
with open(f'video\\{
title}.mp4', mode='wb') as f:
f.write(video_data)
print(title, ' Climb to success !!!')
Okay , My article ends here !
There are more suggestions or questions to comment on or send me a private letter ! Come on together and work hard (ง •_•)ง