Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to download audio novels with Python multithread

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article analyzes "how Python multithreading downloads audio novels". The content is detailed and easy to understand. Friends who are interested in "Python multithreading how to download audio novels" can follow the editor's idea to read it slowly and deeply. I hope it will be helpful to everyone after reading. Let's follow the editor to learn more about "how to download audio novels with Python multithreading".

I specially bought a Note II with a large screen to watch pdf, and my ears can't be idle, but I don't listen to English but novels. I like listening to the radio when I am reading, especially storytelling, crosstalk, etc., so I need a lot of audio novels. Now there are a lot of resources on the Internet, but downloading pages is troublesome, in order to earn more traffic and advertising clicks. The download links to these sites all need to open at least two or more pages to find the real link, which is very troublesome. In order to save the overall download time, I wrote this Mini Program to facilitate myself and you to download audio novels (of course, there are any other types of resources).

To be clear, I am not trying to climb a lot of materials and data, just for entertainment and learning, so I will not aimlessly crawl all the links to a website, but given a novel, for example, I want to download the novel "Childhood". I will find the home page of the novel on my listening and commenting book website and download all mp3 audio with the program, as shown in the following code, all of which are in the module crawler5tps:

1. First set the start url and the directory where the files are saved

#-*-coding:GBK-*- import urllib,urllib2 import re,threading,os baseurl = 'http://www.5tps.com' # baseurl down2path =' Elux EnovelCash'# saving path save2path =''# saving file name (full path)

two。 Parse the url of the download page from start url

Def parseUrl (starturl): 'parse out download page from start url. Eg. We can get 'http://www.5tps.com/down/8297_52_1_1.html' from' http://www.5tps.com/html/8297.html' global save2path rDownloadUrl = re.compile (". *?

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report