Python batch create thunder tasks and create multiple files

Source: Internet
Author: User
Instead of creating a batch task, I used python to create a text file. Each line had a link to be downloaded. Then I opened thunder and copied the content of the text file. Thunder monitored the clipboard changes, the pop-up dialog box for downloading all links does not actually create a batch task, but uses python to create a text file, each line has a link to download, and then starts thunder and copies the content of the text file, when thunder detects the clipboard changes, a dialog box for downloading all links is displayed ~~

This is the actual situation, because it is very difficult to analyze webpages using python, such as downloading all pdf links on a page.

from __future__ import unicode_literalsfrom bs import BeautifulSoupimport requestsimport codecsr = requests.get('you url')s = BeautifulSoup(r.text)links = s.findall('a')pdfs = []for link in links:href = link.get('href')if href.endswith('.pdf'):pdfs.append(href)with open('you file', 'w', 'gb') as f:for pdf in pdfs:f.write(pdf + '\r\n')

Create multiple files using python

# Coding = UTF-8 ''' Created on 2012-5-29 @ author: xiaochou ''' import osimport timedef nsfile (s ): '''the number of new expected events ''' # checks whether a folder exists. If not, create B = OS. path. exists ("E :\\ testFile \") if B: print "File Exist! "Else: OS. mkdir ("E :\\ testFile \") # generate the file for I in range (1, s + 1): localTime = time. strftime ("% Y % m % d % H % M % S", time. localtime () # print localtimefilename = "E: \ testFile \" + localTime + ". txt "# a: open in append mode (can be created if necessary) append; B: indicates that the binary f = open (filename, 'AB') testnote = 'test file' f. write (testnote) f. close () # output the number of files and the corresponding file name print "file" + "+ str (I) +": "+ str (localTime) + ". txt "time. sleep (1) print "ALL Down" time. sleep (1) if _ name _ = '_ main _': s = input ("Enter the number of files to be generated:") nsfile (s)

The above content is the Python batch creation of thunder tasks and the instance code for creating multiple files. I hope it will help you.

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.