Reptile Landing Geek College, and download video

Source: Internet
Author: User

First Note: This code is not free download video, you need to have a VIP account
Just easy for everyone to download in bulk
But the experience VIP is also very good to get, with the experience opportunity to quickly use this batch download it

Complete code in this: my GitHub
Just modify the bottom storage address and pages that need to be downloaded to bulk download all videos from a course in a page to a specific folder

Mainly landing site this piece of waste some time, briefly say the login module:

First of all must have the following part of the code, meaning to the urlopen () function plus cookie processing, otherwise it will not process cookies, but the site records who we are relying on cookies, without which can not be landed, so this part is extremely important

# 初始化一个CookieJar来处理CookiecookieJar = cookielib.CookieJar()# 实例化一个全局openeropener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookieJar))# 把这个cookie处理机制装上去,大概是这个意思-.-urllib2.install_opener(opener)

The following is the processing of the login to send the packet, ready data can be, and then there is a point, is the verification code this piece, I am directly to the verification code to get down, and then display, and finally manually enter the verification code

# Get login parameters from the login pageLogin_url =' Http://passport.jikexueyuan.com/sso/login '# Login information sent to this addressPassport_url =' Http://passport.jikexueyuan.com/submit/login?is_ajax=1 'Verifycode_url =' http://passport.jikexueyuan.com/sso/verify '# Get login page source codeRequest = Urllib2.urlopen (login_url) HTML = Request.read () request.close ()# get log in to post dataexpire = Re.search (R "(? s) value= ' (. *?) ' name= ' expire", HTML)# Verification CodeVerifycodegifpath ='/tmp/jikexueyuan.gif 'Request = Urllib2.urlopen (verifycode_url) gif = Request.read () request.close () fgif = open (Verifycodegifpath,' W ') fgif.write (GIF) fgif.close ()# Read the verification code picture saved to the localOs.system (' EOG '+ verifycodegifpath) Verify = Raw_input ("Please enter the verification code in the figure:") data = {' expire ': Expire.group (1),' Referer ':' http%3a%2f%2fwww.jikexueyuan.com%2f ',' uname ': User name,' Password 'Password' Verify ': Verify,}post_data = urllib.urlencode (data) request = Urllib2. Request (Passport_url,post_data)# Give a useragent to prevent it from being considered a reptile programRequest.add_header (' User-agent ',' mozilla/5.0 (X11; Linux x86_64) applewebkit/537.36 (khtml, like Gecko) chrome/44.0.2403.125 safari/537.36 ')# Send Login RequestRequest = Urllib2.urlopen (Request) Request.close ()Print ' Landing done '

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Reptile Landing Geek College, and download video

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.