laitimes

Zero-code programming: Use ChatGPT to download the Invest Like the Best investment podcast audio in bulk

author:AIGC Tribe

Patrick O'Shaughnessy hosts one of the world's most famous investment podcasts, called Invest Like the Best. The content is about investment concepts, financial management methods, life planning, etc. In each issue, guests will share their investment strategies and products, and will also recommend books.

Zero-code programming: Use ChatGPT to download the Invest Like the Best investment podcast audio in bulk

The entire podcast audio can be downloaded on its official website: https://investlikethebest.libsyn.com

How to use ChatGPT to download in batches?

First of all, look at these podcast audio files, which are all in the div tag of class="libsyn-item";

Zero-code programming: Use ChatGPT to download the Invest Like the Best investment podcast audio in bulk

Then locate the podcast file title:

<div class="libsyn-item-title">

<a href="https://investlikethebest.libsyn.com/scott-davis-rob-wertheimer-lessons-from-the-industrial-titans-invest-like-the-best-ep324">Scott Davis & Rob Wertheimer - Lessons from the Industrial Titans - [Invest Like the Best, EP.324]</a>

Podcast Audio Mp3 is also easy to find:

<div class="libsyn-item-content">

<ul class="libsyn-item-free">

<li>

<a href="https://traffic.libsyn.com/secure/investlikethebest/EP.324_-_Lessons_from_Titans_FINAL.mp3">Download this Episode</a></li>

</ul>

</div>

There are 17 pages in total, and the address of each page is very regular:

https://investlikethebest.libsyn.com/page/1/size/25 p. 1

https://investlikethebest.libsyn.com/page/2/size/25 p. 2

https://investlikethebest.libsyn.com/page/17/size/25 p. 17

Now, you can enter the prompt word in ChatGPT:

You are a Python programming expert and want to complete a task of downloading an audio file from a web page by following these steps:

Open the web page: https://investlikethebest.libsyn.com/page/{pagenumber}/size/25

The value of the parameter pagenumber is from 1 to 17;

Locate the div tag of class="libsyn-item";

Locate the div tag with class="libsyn-item-title" in this div tag, extract the content of the first A tag as the title name of the audio file;

Then, locate the div tag with div class="libsyn-item-content", extract the href value of the a tag as the URL address of the audio file download.

Download the audio file and save it to the folder on the D drive of your computer: invest-like-the-best

Zero-code programming: Use ChatGPT to download the Invest Like the Best investment podcast audio in bulk

chatgpt generates the Python source code as follows:

import os

import requests

from bs4 import BeautifulSoup

# Create a folder where you can save the audio files

if not os.path.exists('D:/invest-like-the-best'):

os.makedirs('D:/invest-like-the-best')

# Iterate through each page

for pagenumber in range(1, 18):

url = f'https://investlikethebest.libsyn.com/page/{pagenumber}/size/25'

response = requests.get(url)

# Parse the content of the web page

soup = BeautifulSoup(response.text, 'html.parser')

# Navigate to each audio item

for item in soup.find_all('div', class_='libsyn-item'):

# Extract audio titles

title = item.find('div', class_='libsyn-item-title').a.text

# Extract the audio download link

download_url = item.find('div', class_='libsyn-item-content').a['href']

print(f'Downloading {title}...')

# Download the audio file

audio_response = requests.get(download_url)

# Save the audio file

with open(f'D:/invest-like-the-best/{title}.mp3', 'wb') as f:

f.write(audio_response.content)

print(f'Downloaded {title}!')

Zero-code programming: Use ChatGPT to download the Invest Like the Best investment podcast audio in bulk

Run, download successfully:

Zero-code programming: Use ChatGPT to download the Invest Like the Best investment podcast audio in bulk

Read on