Save python crawling web video to a local

Foreword

The text of text and images from the network, only to learn, exchange, not for any commercial purposes, belongs to original author, if any questions, please contact us for treatment.

Author: Woo_home

PS: If necessary Python learning materials can be added to a small partner click the link below to obtain their own

http://note.youdao.co-m/noteshare?id=3054cce4add8a909e784ad934f956cef

Installation Library

This example uses the library to have requests, lxml, re, where re is the python comes, there is no need to install, the installation only requests to the library and lxml

Installation command as follows:

pip install requests
pip install lxml

Analysis of data pages

Open a video page is as follows:

Here Insert Picture Description

Right-be developer mode, right-click on a video, click Open in new tab

Here Insert Picture Description

ok, you can open

Here Insert Picture Description

Code

First import library to be used

import requests
from lxml import etree
import re

Get the site UR L

Here Insert Picture Description

Gets User-Agent

Here Insert Picture Description

Initiate a request

Here Insert Picture Description

Screening data

Here Insert Picture Description

Through the data

Here Insert Picture Description

Match with data

Here Insert Picture Description

save data

Here Insert Picture Description

Download video has been saved in a folder

Here Insert Picture Description .

Guess you like

Origin www.cnblogs.com/Qqun821460695/p/11917666.html