First of all, I sigh, ChatGPT is really powerful. I thank it.
This article shares a piece of code it wrote. It is used to download the specified suffix file of a specified page.
Specifically, download through this code
https://www.3gpp.org/ftp/Specs/2022-12/Rel-18/38_series
All zip files under this link.
That is, the latest R18 38 series specification released in December 2022.
The original page is as follows:
The code execution process through ChatGPT will prompt that the download is in progress:
The result of the final download:
The following is the code sharing, and you can download other specifications by making inferences with a little modification.
Thanks for writing better than ordinary programmers. sharp.
I put this py file on the 51 Communication website for download.
download link:
The code written by ChatGPT is as follows:
[Again, I didn't write it, it was written automatically by ChatGPT. It was written in less than 30 seconds. 】
import us
import re
import requests
from bs4 import BeautifulSoup
def get_zip_urls(url):
"""
Get the url of the zip file
"""
html = requests.get(url).text
soup = BeautifulSoup(html, 'lxml')
zip_urls = []
for a in soup.find_all('a'):
if a.get('href').endswith('.zip'):
zip_urls.append(a.get('href'))
return zip_urls
def download_zip(url, path):
"""
download zip file
"""
if not os.path.exists(path):
os.makedirs(path)
zip_urls = get_zip_urls(url)
for zip_url in zip_urls:
zip_name = re.search(r'[^/]+$', zip_url).group()
print('正在下载{}'.format(zip_name))
with open(os.path.join(path, zip_name), 'wb') as f:
f.write(requests.get(zip_url).content)
if __name__ == '__main__':
url = 'https://www.3gpp.org/ftp/Specs/2022-12/Rel-18/38_series'
path = 'zip'
download_zip(url, path)