Simple! Direct! Rough! Three steps! Batch access the learning video under the learning power page (. End of mp4)

Keywords: Selenium Big Data JSON Database

Do a little help to the old students, consolidate the practice of request, selenium, xpath, download the video link at the end of. mp4 in batch, and directly go to the code and ideas.

Batch access to learning videos under the page of learning power

1. Target url

url = 'https://www.xuexi.cn/ef46fcc98c121cc7ccb9905133bee723/data9b0f04ec6509904be734f5f609a3604a.js'

2. Clarify the purpose of reptile, analyze the target webpage, and sort out the reptile ideas

2.1 define the purpose of reptile

  1. Course link of early target web page to realize the jump of web page
  2. Find the download link of the video under the course page after jump
  3. Name the file with the course name and download the corresponding. mp4 video in batch

2.2 analysis target page

Target webpage (this is a webpage of learning power, which contains all course names):

Check the source code, analyze the structure of the web page, find the jump link address of each course.

When you directly locate the course name and check its source code, you can find that you can't find its jump link, but you can see many style and css codes. Probably, what the page presents is what you get after rendering. Generally, the data of this kind of web page is loaded through js, and then you can use the Network panel of chord to view each request and find the js request with data , view in ALL.

After a while, you can see that there is a js request named data with html request parameters at the beginning and then. Open it and see that the data displayed on the page is really stored in it, which contains the name, id, jump link, etc. of the course, so that the jump link of the course can be found. And view the returned results:

The next step is to jump through the link to find the download link of the video.

You can directly view the source code of the web page by locating the video. You can clearly see that the download link of the video is in the src attribute of the video tag, so it's easy to do.

2.3 combing reptile ideas

  1. Crawl all course jump links down
  2. Respectively loop to grab the source code of each link after jump
  3. Use xpath to grab the download address of the link

3. Upper code

3.1 crawl the jump links of all course pages.

# Set request header
headers = {
    'Accept': '*/*',
    'Host': 'www.xuexi.cn',
    'Referer': 'https://www.xuexi.cn/ef46fcc98c121cc7ccb9905133bee723/9b0f04ec6509904be734f5f609a3604a.html',
    'Cookie': '__UID__=c1d73200-b376-11ea-972e-3dda609d092c',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36'
}


url = 'https://www.xuexi.cn/ef46fcc98c121cc7ccb9905133bee723/data9b0f04ec6509904be734f5f609a3604a.js'
response = requests.get(url,headers=headers)
response.encoding = response.apparent_encoding
# The result returns str type, which is convenient to handle and change to json format or dictionary
data = response.text.lstrip('globalCache = ').rstrip(";")
text = json.loads(data)
# Save all course links
url_list = []
# Save all course names
url_name = []
for i in text.get('fpe1ki18v228w00'):
    url_list.append(i.get('static_page_url'))
    url_name.append(i.get('frst_name'))

3.2 use selenium to crawl the video download link after webpage jump

Because it's simple and rough, I used selenium directly, and I didn't use multithreading, so the crawling speed was a little slow.

def get_url_mp4(list):
    url_mp4_list = []
    for url in list:
        driver = webdriver.Chrome()
        driver.get(url)
        time.sleep(1)
        tree = etree.HTML(driver.page_source)
        url_mp4 = tree.xpath('//video[@autoplay="autoplay"]/@src')
        url_mp4_list.append(url_mp4)
        driver.close()
    return url_mp4_list

4. Download videos in batch and name video files with course name

In the previous operation, the course name and the corresponding video download link have been obtained, which can be downloaded directly in batch: (create another. py file to download)

#coding=utf-8

import os
from contextlib import closing
import requests

name = ['00-01 What is social investigation and research method', '00-02 Course segmentation and purpose', '00-03 Teaching materials and reference materials', '00-04 Teaching arrangement', '01-01 Natural and social phenomena (1)', '01-01 Natural and social phenomena (2)', '01-02 Characteristics of social phenomena (1)', '01-02 Characteristics of social phenomena (2)', '01-03 Scientific thinking and Social Research (1)', '01-03 Scientific thinking and Social Research (2)', '01-04 Social science and social investigation', '01-05 Ethics and politics of social investigation and Research (1)', '01-05 Ethics and politics of social investigation and Research (2)', '02-01 From common sense to theory (1)', '02-01 From common sense to theory (2)', '02-02 Theory of Social Science (1)', '02-02 Theory of Social Science (2)', '02-03 Theoretical and empirical research', '02-04 Social investigation and theory (1)', '02-04 Social investigation and theory (2)', '02-05 Social investigation and the evolution of theory', '03-01 scientific experiment', '03-02 Principle of experimental method (1)', '03-02 Principle of experimental method (2)', '03-03 Experimental design (1)', '03-03 Experimental design (2)', '03-04 Experimental method, social research and investigation method', '04-01 Research questions and purposes', '04-02 Sources of research questions', '04-03 Basis for selecting research questions', '04-04 Turn research problems into research topics', '05-01 What is research data', '05-02 Form of research data', '05-03 Source of research data', '06-01 Variable concept (1)', '06-01 Variable concept (2)', '06-02 Variable type of measurement', '06-03 Measuring tool (1)', '06-03 Measuring tool (2)', '06-04 Quality inspection of measurement (1)', '06-04 Quality inspection of measurement (2)', '07-01 What is sampling', '07-02 Elements of sampling', '07-03 Sampling logic (1)', '07-03 Sampling logic (2)', '07-04 Probability sampling (1)', '07-04 Probability sampling (2)', '07-04 Probability sampling (3)', '07-04 Probability sampling (4)', '07-04 Probability sampling (5)', '07-04 Probability sampling (6)', '07-04 Probability sampling (7)', '07-04 Probability sampling (8)', '07-05 Non probability sampling', '07-06 Sampling plan', '07-07 Sampling implementation', '08-01 What is the implementation plan (1)', '08-01 What is the implementation plan (2)', '08-02 Technical proposal', '08-03 Organizational plan', '08-04 Management plan', '09-01 What is a research proposal', '09-02 Research questions', '09-03 research contents ', '09-04 Operation plan', '09-05 Expected results', '09-06 Summary, budget, team', '10-01 Elements of the questionnaire', '10-02 The design of questionnaire structure (1)', '10-02 Design of questionnaire structure (2)', '10-03 The design of questionnaire subject (1)', '10-03 The design of questionnaire subject (2)', '10-03 The design of questionnaire subject (3)', '10-04 The design of questionnaire auxiliary content', '10-05 Type of questionnaire', '10-06 Implementation of questionnaire survey', '10-07 Management of questionnaire', '11-01 What is interview survey', '11-02 Structured interview', '11-03 Unstructured interview', '11-04 depth interview ', '11-05 Thematic groups', '12-01 What is observational investigation', '12-02 Laboratory observation', '12-03 Participating observation and non participating observation', '12-04 Structural observation and unstructured observation', '13-01 What is literature research', '13-02 Types of literature (1)', '13-02 Types of literature (2)', '13-03 Methods of literature investigation (1)', '13-03 Literature survey method (2)', '14-01 Trace evidence, data', '14-02 Big data as trace data', '14-03 Big data survey method', '15-01 Types of survey data', '15-02 Collation of survey data', '15-03 Cleaning up of survey data', '15-04 Database of survey data (1)', '15-04 Database of survey data (2)', '16-01 Survey data quality', '16-02 Coverage error', '16-03 Measurement error', '16-04 Responsive error', '16-05 Sampling error', '17-01 Understanding case studies (1)', '17-01 Understanding case studies (2)', '17-02 Design of case study (1)', '17-02 Design of case study (2)', '17-03 Collection of case data', '17-04 Quality and analysis of case data', '17-05 Case report', '18-01 statistical analysis', '18-02 Univariate analysis', '18-03 Bivariate analysis', '18-04 Multivariate analysis (1)', '18-04 Multivariate analysis (2)', '19-01 Big data and data mining', '19-02 Types of data mining', '19-03 Data mining technology', '20-01 Characteristics of investigation and research results', '20-02 Investigation and expression of research results', '20-03 Academic papers', '20-04 research report']
url = ['https://video.xuexi.cn/video/1012/p/94d1fa6f81e08e9a5377c42d4e51b463-bd0362fdc9ee4a0bb0cb56284a51df05-2.mp4', 'https://video.xuexi.cn/video/1012/p/24cb7c442efb9186416daea83f2c7989-b2d5ac10dd24403d8d11f8d534be670a-2.mp4', 'https://video.xuexi.cn/video/1012/p/d0e8c270e4c05602402f5b981bc36deb-3d62bc3c1b4b43fa9186488d3c82f69d-2.mp4', 'https://video.xuexi.cn/video/1012/p/2087f8343dff7541f1e818a125b4ba4c-32ef017c95be4cb58da716ca4b35c227-2.mp4', 'https://video.xuexi.cn/video/1012/p/c53bc46d3cda8b6a04e0741a2f32908a-40336a563b004d3796e5384da63e35f9-2.mp4', 'https://video.xuexi.cn/video/1012/p/e524185a9edbb37973b3ec4dfa453f4c-644662817c6a463298f07d2f9ea0a815-2.mp4', 'https://video.xuexi.cn/video/1012/p/de47580bbeb1dbb125c69f496b15d610-1bd3e0b0d58c4186917a71e3d0533919-2.mp4', 'https://video.xuexi.cn/video/1012/p/526054945e83a953903389a4529ec625-e79aec93055a44538c09ace45706dc53-2.mp4', 'https://video.xuexi.cn/video/1012/p/70f8def503557cb62cfe6068c594cfd4-4fc8c336c8b4486cb329218795b8a6f7-2.mp4', 'https://video.xuexi.cn/video/1012/p/5fe719f5f20cbb91ef3cac9bd9f8efd2-09d0b266013445198b88a11919a017f3-2.mp4', 'https://video.xuexi.cn/video/1012/p/ea91bd32df04ac2fd46aa79384bdbc38-64b8af86024f4816b7028e747ac0d342-2.mp4', 'https://video.xuexi.cn/video/1012/p/9981a260b0527d4e8197b7ca73acd93b-04eb985400244af5ae4ef3a60e41ec65-2.mp4', 'https://video.xuexi.cn/video/1012/p/ba707b80aec84d5e48e374fdb6f543e8-3b9de57669ba4ead89b3ff26556e7c3c-2.mp4', 'https://video.xuexi.cn/video/1012/p/0f43c638b3a233a10b23c03e77e195a6-7d5afa239d0a48c6a7669c2f894c62da-2.mp4', 'https://video.xuexi.cn/video/1012/p/e8b9bbf21be4457b626a896464b596c4-ea0d14f2cfbf4f46a0982615efdd445e-2.mp4', 'https://video.xuexi.cn/video/1012/p/c64921f3c24a8a711ae43c3d77127fde-3c1d332913384b239fe7cccdbea73163-2.mp4', 'https://video.xuexi.cn/video/1012/p/21341cca3d5b97ec25a256a0a9967ede-c47eaffe834d4f9f8d08296686bc01b1-2.mp4', 'https://video.xuexi.cn/video/1012/p/cc29c54c1e2270523f92243f27d2add8-5110118873464958aa1bd017cbb69197-2.mp4', 'https://video.xuexi.cn/video/1012/p/a503fa67f01908dc8798f832e553631a-c6f4c267205a41c49215b60500337769-2.mp4', 'https://video.xuexi.cn/video/1012/p/719b1453c4717db59b9a3e111e7d1838-95c8dc3367ea4af68050394410928013-2.mp4', 'https://video.xuexi.cn/video/1012/p/c315f02d750bd9a0ac9b75557bac777e-1e80cbd21d9649909a9c7dc3fa11ede5-2.mp4', 'https://video.xuexi.cn/video/1012/p/40ac22d6a807d5e650aa2d9ef0a9753e-54d8be468da54ac9ae9a8c0ea0f8d97a-2.mp4', 'https://video.xuexi.cn/video/1012/p/0765bb27711ca2072fc312fdd7ea29a9-01f769f4d4b440119638793c4759b8c6-2.mp4', 'https://video.xuexi.cn/video/1012/p/5bf12b2e5a5bc8c9cb55ccbe127b619d-b60ce22809fd4182b47198e97dcec7cf-2.mp4', 'https://video.xuexi.cn/video/1012/p/231d7eb77cb95344ae9909e11b60edc1-f42be5291c7b4bc0b264f7f2d511213c-2.mp4', 'https://video.xuexi.cn/video/1012/p/f14a6806a28ff7d6e06831feff134c79-a34c5fa3b9ff4c66a2abf2973541e69f-2.mp4', 'https://video.xuexi.cn/video/1012/p/5630bb3d831be2ff692691d582727d73-097789dce31a4867b098ae35b7b8b366-2.mp4', 'https://video.xuexi.cn/video/1012/p/c60e259952c0a7423f8bcb7fdedf41e4-d023476c807448e78a1a5222d85011c0-2.mp4', 'https://video.xuexi.cn/video/1012/p/60c19a704b5468fcc8439041769ce8f3-570fafca5d2c4e6488ff465b2f554d4a-2.mp4', 'https://video.xuexi.cn/video/1012/p/e3a3e9c19c1b1d573ed6f4880de74ef7-e4bf15ca7d0d46b28fb31409674c22cf-2.mp4', 'https://video.xuexi.cn/video/1012/p/7ffceb7036a2d7a4bdf1d2278ec223ae-b865516917b54368a60576a1668efb47-2.mp4', 'https://video.xuexi.cn/video/1012/p/ddffa64433bed237b8bf8937719c28ea-297252f43e5c4ad3bd374d916794b520-2.mp4', 'https://video.xuexi.cn/video/1012/p/7ccec8e804bc3ddc1812102783bd9197-61f01d2dd6374872a3e8dd19d5acb21b-2.mp4', 'https://video.xuexi.cn/video/1012/p/70aae8422c0015bdf37794935764cb78-8135caa3dcb349898d257b9e00edf85a-2.mp4', 'https://video.xuexi.cn/video/1012/p/42c6b5140452359c42e1bcb04a10046f-9be3e969700745ca82344f9a95cb1232-2.mp4', 'https://video.xuexi.cn/video/1012/p/032022fc633daf2312ea5be78535cf96-10214795bb2447bd81190ee3b8085c43-2.mp4', 'https://video.xuexi.cn/video/1012/p/401e2cc8b1113753d9d1040cc83d9a60-55f7a641b4b64b0bae401b48cf4198f4-2.mp4', 'https://video.xuexi.cn/video/1012/p/7a60d93e0909143e436e93047191d5fb-59a9826fb5674480b942f101d3bc8486-2.mp4', 'https://video.xuexi.cn/video/1012/p/6dc16e2d054eff4aab3ebc6d3ea39bd1-6e9adccc6ad84f278375ebe35fcce092-2.mp4', 'https://video.xuexi.cn/video/1012/p/50570302a94c56c5728991c6c3c5f738-41740ff4daec4343a11838e54c5e59b0-2.mp4', 'https://video.xuexi.cn/video/1012/p/c62a9a364466153b4f271e0bb4bfe216-dd5316a2507c4b91aa90dde2d1627c16-2.mp4', 'https://video.xuexi.cn/video/1012/p/141769168fd550512bd1a56444a72043-a13ca1130afc4084acdd369ed6a42e1f-2.mp4', 'https://video.xuexi.cn/video/1012/p/ecefc54566fdfa527893c73e9fc4c381-173030fde25f467fa6fbecebe51c975e-2.mp4', 'https://video.xuexi.cn/video/1012/p/3040c2247c802055f69f973dc0a818f8-baed61484a7d47d4bb65dcf00cacf5f2-2.mp4', 'https://video.xuexi.cn/video/1012/p/c7fb7cbb7234e5a5c35da512c4585c25-10e378929023480aa87919991f4acb3b-2.mp4', 'https://video.xuexi.cn/video/1012/p/4d3486e0fc7a0518864e2b6473bcebe1-772eade01a2d499fb54c4d6929db2cb1-2.mp4', 'https://video.xuexi.cn/video/1012/p/5b8455ba017822439f017f578ec90c1e-01e7e9ff30b447669b83e816b71b5a4b-2.mp4', 'https://video.xuexi.cn/video/1012/p/cede3a58e44ee58b74291daaeb8393d9-01f3bf2594524b17b3b4d12b714d8a4c-2.mp4', 'https://video.xuexi.cn/video/1012/p/45a52874aa131f3bb35be14839287b88-1b6dc86d674e4e1cb09e33c7dd58581b-2.mp4', 'https://video.xuexi.cn/video/1012/p/c97672b755dfc8e5d1084969a0b4ccca-6326df4bb22a44088ab6bd0718c997e2-2.mp4', 'https://video.xuexi.cn/video/1012/p/41b8ed0e08f7686124a7fa1326ce3199-0a25ee955a794c098499b003509d3751-2.mp4', 'https://video.xuexi.cn/video/1012/p/8b0f56ab4c12856660ed716646d91ff8-9e8e946eb60145899c44885356f8a09f-2.mp4', 'https://video.xuexi.cn/video/1012/p/d8d2316e191f8da7125b298d7989c7ba-ecdbe1e64b8e4f15bba8f9487d0ff554-2.mp4', 'https://video.xuexi.cn/video/1012/p/0003a3f8312d5d4bccc1484f32517b87-a6da88984481422e8ef9ee9f2af50004-2.mp4', 'https://video.xuexi.cn/video/1012/p/7281a5764711640daa6e2f6c459fba73-cfe6947b7bfd425cabea3395606b591c-2.mp4', 'https://video.xuexi.cn/video/1012/p/a91405f1a0c05938b0be0dc7189da233-f1bb1562b34647b1ab4cdfb2e7f0b39b-2.mp4', 'https://video.xuexi.cn/video/1012/p/6150edeec452651120e46855cd64525d-743231300f4545e6914d74d4ec8ac03e-2.mp4', 'https://video.xuexi.cn/video/1012/p/e58dfeb5e74e40b03dac1f1a44c75bf2-ba259c6c6d454afd88e27c3df3c78089-2.mp4', 'https://video.xuexi.cn/video/1012/p/653f43561911a03c6bc39598b42467fc-21dc74d21a484765b8c04cb02c45a08d-2.mp4', 'https://video.xuexi.cn/video/1012/p/52f53d9f89af9d4df06b97bb7d79fa85-452dd18cd79b4fbe89be2c8d16ec3799-2.mp4', 'https://video.xuexi.cn/video/1012/p/a7af905f7c2f6cb29e71ad8f52958275-c354f526101545298d7afe5e18f9b5bf-2.mp4', 'https://video.xuexi.cn/video/1012/p/301c18cf7624c54360e515d93292641c-6692eec0fa7041059396eed36dce0a07-2.mp4', 'https://video.xuexi.cn/video/1012/p/2b2825d4f35ddcd4d3671a96bad44bf3-2f3050a489c9468e95a338396a3937d6-2.mp4', 'https://video.xuexi.cn/video/1012/p/76f69265609d98a719b1ca559f1da546-80119bcb182a4b869147184202e54da1-2.mp4', 'https://video.xuexi.cn/video/1012/p/62801ad1c12059c5f69b02456ba361d5-0d382e1cfcb1438e9e3d116e6de5f66b-2.mp4', 'https://video.xuexi.cn/video/1012/p/af352752588d92e8c995722ae6c02ec8-99b27701ccf949a69aea34cb64807905-2.mp4', 'https://video.xuexi.cn/video/1012/p/cc772f9259a0db4b4e7bfa13ceb4a0dc-b0d33e8adc5c4e179a497d114d2e404a-2.mp4', 'https://video.xuexi.cn/video/1012/p/d6c2c690fe92293e7b9465c5ca8000ec-5b77001e8856408eb5d5b85b8a5d22e3-2.mp4', 'https://video.xuexi.cn/video/1012/p/cd82a0c2748afba7a9170b38581dfdd5-30e12a33d551428b9d25c1503c04ced5-2.mp4', 'https://video.xuexi.cn/video/1012/p/ae0d058b6f7803d03ea7aa14d442ed0e-0d89cec5e9ca408eaf2b61eb3c7d7f17-2.mp4', 'https://video.xuexi.cn/video/1012/p/79e33fbdf7ec82cb1ca4b462c89ba551-184c7c428eec4fe489ec09e40fcb33b3-2.mp4', 'https://video.xuexi.cn/video/1012/p/8306a9205f124bb2a5fe7a840543dc77-d9c7b173d7c849999a3700d852e3da63-2.mp4', 'https://video.xuexi.cn/video/1012/p/05934b2502b01b16ec1baba9c7ff9382-65f79045e19e41d998b7f222e4ddf865-2.mp4', 'https://video.xuexi.cn/video/1012/p/90727ff8563d4a44cc64bc803ce6ee4f-d08d0e0dd42243399c8efcf48d851808-2.mp4', 'https://video.xuexi.cn/video/1012/p/46679dedfae5135a35f5f889d3f4d367-08148bec736949a49d1a5530c231246c-2.mp4', 'https://video.xuexi.cn/video/1012/p/eb4762f7d17c881b42bf12888920d6da-0fd63994a7db4ab9830378e837f250a0-2.mp4', 'https://video.xuexi.cn/video/1012/p/b24c334507aa6d03a8e67b64c4b43e33-8174e78f4d464ef0bd2b44fb888fb1f1-2.mp4', 'https://video.xuexi.cn/video/1012/p/1b470a352557adcd554039ff1bc431a1-97bf691a6d9b4b479b918a47a53caba0-2.mp4', 'https://video.xuexi.cn/video/1012/p/24a799663394f45bfcefa5c393ec81ec-b4c454747ce4448783a24761a0d2d976-2.mp4', 'https://video.xuexi.cn/video/1012/p/50902e0beea223a55bfcf2f2e816c82e-e3db59e7c3b54fea94d732bcb0766716-2.mp4', 'https://video.xuexi.cn/video/1012/p/c355e82712d57be72f992fef27b2b101-ee93fa485e634df2b5e36b6534e29864-2.mp4', 'https://video.xuexi.cn/video/1012/p/f9fa67edbd46a669ed6c858bfb46580a-3d647a5e414f4ada9501619bd7321a18-2.mp4', 'https://video.xuexi.cn/video/1012/p/97088f72d95ea660c6cce049ff90e7e6-87104d9c2b5a4e6e958e483345457ab1-2.mp4', 'https://video.xuexi.cn/video/1012/p/5deaa9d8fb0d8615bca2bab8c026246c-2aec4a86d69b4694a264b02501a7908f-2.mp4', 'https://video.xuexi.cn/video/1012/p/502aba31718ed6cc9012e9fcb17bad64-226d1f74a3414fdf9b1ce55255a0b00f-2.mp4', 'https://video.xuexi.cn/video/1012/p/d90406da1fb84d70fa44a16e41829689-6b99fe43ad964eaa99784a6b963b1c77-2.mp4', 'https://video.xuexi.cn/video/1012/p/7c90a095fbce8e65a82b92eaaed7b898-ff9d6fa1604a4e98a034bfcc6e5edad0-2.mp4', 'https://video.xuexi.cn/video/1012/p/47d97744099ce0c1ad61f62ee203615f-aa12f334629c4441a4deb153435ce047-2.mp4', 'https://video.xuexi.cn/video/1012/p/8e7763350cd19a9563cd5eece89e9eb3-c20985c00fc0449e9b7b97a7c3ac944e-2.mp4', 'https://video.xuexi.cn/video/1012/p/6e99ab27f16622953e3ddcd08edb1eda-9a8af6ac8da74385afc5ff2f16be17d8-2.mp4', 'https://video.xuexi.cn/video/1012/p/b8b1a6b4711aa44ce5cabdd0b4c4abe8-9951fb907ac44a4cbc8cc7f6eb9c2b81-2.mp4', 'https://video.xuexi.cn/video/1012/p/793c730cb726d809e866a211f604aa2f-7379ada910d74cabbd42ddae5429d012-2.mp4', 'https://video.xuexi.cn/video/1012/p/900c0b6977b1932fba2fa9f1034a2e71-7477cc7d14ea4c429d89fe2f455b368b-2.mp4', 'https://video.xuexi.cn/video/1012/p/e3e04018852eb89c7a42cf0a82b11ac8-c68a2ba5d470409eb29728aded549bf1-2.mp4', 'https://video.xuexi.cn/video/1012/p/10c7974dbef1a58d7b44d4664eb843ba-ef0834d87bfc414dad3e9292c341c503-2.mp4', 'https://video.xuexi.cn/video/1012/p/e9569a94c269f06eaeb17874a9d6ec65-beb8040f5ec8453dae3c5f9001582e09-2.mp4', 'https://video.xuexi.cn/video/1012/p/b63c079446d8f4304a6b7274506ccc9b-6b66b13cd44e4549827e52ef36659caf-2.mp4', 'https://video.xuexi.cn/video/1012/p/697daaa1fff074046e137660a6461221-ea3ee847676a451bb5424cfbb4f9f5ea-2.mp4', 'https://video.xuexi.cn/video/1012/p/473ca418dee46d04769b96058fc0d612-67b0931c3a8d4a2eb88c3c9436997d46-2.mp4', 'https://video.xuexi.cn/video/1012/p/c2f21d1cde85b59be863f64432f58c6a-50b356ba5ff842d4acebc76900b696eb-2.mp4', 'https://video.xuexi.cn/video/1012/p/940aa2daf3a365252fc389bbe8a8fc6b-abfba5c60a5b4853bb5cadd8598306eb-2.mp4', 'https://video.xuexi.cn/video/1012/p/b593cd583d69b8a7b3fe0d038f29a5ea-48dad39b42374588b23b11af8a00dc73-2.mp4', 'https://video.xuexi.cn/video/1012/p/fc8556ad56b9fd3860a8066f12f44e32-548581eb915f449e98156591d8d118ae-2.mp4', 'https://video.xuexi.cn/video/1012/p/19694b48b1acfc5d47788499df0475b0-dd80408e103f4e2080403f423a27e7af-2.mp4', 'https://video.xuexi.cn/video/1012/p/b03b5329733d93ab7e190116d0b9991e-b2d99ecbde8c4913b9fbeebf6f1a71d5-2.mp4', 'https://video.xuexi.cn/video/1012/p/180941ce6ee0be960b247d76f5bf3ba5-7c659c7cbed9420993e52b4c991865d0-2.mp4', 'https://video.xuexi.cn/video/1012/p/035e04922b8b901bc3ab85e48ff15a6f-b2fdb1816b6f4e138b9e3ee4e0358b8c-2.mp4', 'https://video.xuexi.cn/video/1012/p/c3d522e97573464524805b22e23d6429-69aff941ac884d05b21109812084c979-2.mp4', 'https://video.xuexi.cn/video/1012/p/33abe0a669abb4e29c9463c0f26f3a83-280d1d94e4b84a0184de7eb6ca7ea606-2.mp4', 'https://video.xuexi.cn/video/1012/p/426dc9cef09de8f357fe7393dde85414-fe06c4a8918542ab91cbfda8bd4f0ad1-2.mp4', 'https://video.xuexi.cn/video/1012/p/30be6f736e22fc0cabbf2ac7b0ab6a22-e436b4d174de4ba285b13776db4102c8-2.mp4', 'https://video.xuexi.cn/video/1012/p/f6ccc92698134a96aa280a6ed1b165ec-56984f7d136741fe90a91d5830d789d0-2.mp4', 'https://video.xuexi.cn/video/1012/p/b208a60abbd6db171f0b0e621f316466-270c2dfc93e74bbaa458df105c6aaf42-2.mp4', 'https://video.xuexi.cn/video/1012/p/9bc6c9176d651d7960fd831b8d4a70e7-e957b08081374831b2ca5de0e220a832-2.mp4', 'https://video.xuexi.cn/video/1012/p/e26e940a49dc31d41a7766cba7edf318-ed1de77c099b49a9a45a64452238aabc-2.mp4', 'https://video.xuexi.cn/video/1012/p/19f9bcf4ae196e6dcdc62d1e99fbec00-f9c2cb6c814343dcb16dddb0dc773193-2.mp4', 'https://video.xuexi.cn/video/1012/p/cd68491a955a4b0600938891dcca3289-7774fec06671406fad6c814f90f1c2ce-2.mp4', 'https://video.xuexi.cn/video/1012/p/f3f94b5bc6f9c60a6cf549b5ed9005cd-1104f42bd83e4596ad9bdeaccb4455ea-2.mp4', 'https://video.xuexi.cn/video/1012/p/583dd07eee814fa96653d8a3c77c741b-699b0276d4db4c9d8476db80d20fb6f2-2.mp4', 'https://video.xuexi.cn/video/1012/p/d45c1b4752185a963eac9f196bea44e6-aa54a78cab514e009b72fd4e60589f7a-2.mp4', 'https://video.xuexi.cn/video/1012/p/b31e9d3ab7687784cf5a75b772efbc3e-69973224e03843fd8d6ae2609659a010-2.mp4', 'https://video.xuexi.cn/video/1012/p/92486f44c8ec12ad490da8679257304a-c83a05d15f3d4d5093b6094694878b58-2.mp4', 'https://video.xuexi.cn/video/1012/p/52f1ebd85abc49fe0efc7fd5b1979157-9d87341307d74e1880d42bf6efd73e32-2.mp4']

for i in range(len(url)):
    with closing(requests.get(url[i], stream=True)) as response:
    	# Set the size of the download stream
        chunk_size = 1024
        # Stored path
        file_D = r'E:\PycharmProjects\video' + name[i] + '.mp4'
        with open(file_D, "wb") as file:
            for data in response.iter_content(chunk_size=chunk_size):
                file.write(data)

5. Download results


Is it very simple! Direct! Rough!

Posted by gloeilamp on Sun, 21 Jun 2020 03:20:28 -0700