我有以下程式碼用作將單一微信文章內容轉存為特定CSV：
import requests
from bs4 import BeautifulSoup
import base64
from urllib.parse import urljoin
import csv
import re

def get_base64_image(url, headers):
    try:
        resp = requests.get(url, headers=headers, timeout=10)
        resp.raise_for_status()
        b64 = base64.b64encode(resp.content).decode()
        return b64
    except Exception as e:
        print(f"圖片下載失敗 {url}: {e}")
        return None

def parse_publish_time(timestr):
    """
    將 “2025年07月01日 17:27” 格式轉成 “2025-07-01 17:27:00”
    """
    if not timestr:
        return ""

    match = re.match(r'(\d{4})年(\d{1,2})月(\d{1,2})日\s+(\d{1,2}):(\d{1,2})', timestr)
    if not match:
        return ""

    year, month, day, hour, minute = match.groups()
    month = month.zfill(2)
    day = day.zfill(2)
    hour = hour.zfill(2)
    minute = minute.zfill(2)

    return f"{year}-{month}-{day} {hour}:{minute}:00"

def get_article_info(url):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
                      'AppleWebKit/537.36 (KHTML, like Gecko) '
                      'Chrome/90.0.4430.212 Safari/537.36',
        'Referer': 'https://mp.weixin.qq.com/'
    }

    resp = requests.get(url, headers=headers)
    resp.encoding = 'utf-8'
    if resp.status_code != 200:
        print(f"無法取得頁面：狀態碼 {resp.status_code}")
        return None

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

    # 1. 標題（h1#activity-name）
    title_tag = soup.find('h1', id='activity-name')
    title = title_tag.get_text(strip=True) if title_tag else ""

    title_base64 = base64.b64encode(title.encode('utf-8')).decode()

    # 2. 發佈時間（em#publish_time）
    publish_time_el = soup.find('em', id='publish_time')
    publish_time_str = publish_time_el.get_text(strip=True) if publish_time_el else ""
    held_date = parse_publish_time(publish_time_str)

    # 3. 封面圖片（div#js_row_immersive_cover_img > img）
    cover_base64 = ""
    cover_div = soup.find('div', id='js_row_immersive_cover_img')
    if cover_div:
        cover_img = cover_div.find('img')
        if cover_img and cover_img.get('src'):
            cover_url = cover_img['src']
            # 轉Base64
            b64 = get_base64_image(cover_url, headers)
            if b64:
                ext = cover_url.split('.')[-1].lower()
                if ext not in ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp']:
                    ext = 'jpeg'
                cover_base64 = f"data:image/{ext};base64,{b64}"

    # 4. 文章內容（div#js_content）
    content_div = soup.find('div', id='js_content')
    if not content_div:
        print("找不到文章內容節點")
        return None

    content_soup = BeautifulSoup(str(content_div), 'html.parser')

    # 5. 將文章內所有圖片置換成Base64 Data URI
    imgs = content_soup.find_all('img')
    for img in imgs:
        src = img.get('data-src') or img.get('src')
        if not src:
            continue

        # 網址補全
        if src.startswith('//'):
            src = 'https:' + src
        elif src.startswith('/'):
            src = urljoin(url, src)

        b64 = get_base64_image(src, headers)
        if b64:
            ext = src.split('.')[-1].lower()
            if ext not in ['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp']:
                ext = 'jpeg'
            data_uri = f"data:image/{ext};base64,{b64}"
            img['src'] = data_uri
            if 'data-src' in img.attrs:
                del img.attrs['data-src']

    # 6. 組裝完整HTML（含標題和文章內容）
    full_html = f"""<html>
{str(content_soup)}
"""

    description_b64 = base64.b64encode(full_html.encode('utf-8')).decode()

    # 7. 給固定欄位及slug（用title當slug）
    category_id = 12
    author_id = 1
    slug = title
    status = 1

    return {
        'category_id': category_id,
        'author_id': author_id,
        'title': title,
        'title_base64': title_base64,
        'description': description_b64,
        'image': cover_base64,
        'slug': slug,
        'status': status,
        'held_date': held_date
    }

def save_to_csv(data_list, filename='wechat_articles.csv'):
    fieldnames = [
        'category_id',
        'author_id',
        'title',
        'title_base64',
        'description',
        'image',
        'slug',
        'status',
        'held_date'
    ]

    with open(filename, 'w', newline='', encoding='utf-8') as csvfile:
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
        writer.writeheader()
        for data in data_list:
            writer.writerow(data)

if __name__ == '__main__':
    url = 'https://mp.weixin.qq.com/s/WUqNkI-OJfeEIoAgXyhw3A'
    article_data = get_article_info(url)

    if article_data:
        print("文章標題:", article_data['title'])
        print("封面圖片長度:", len(article_data['image']) if article_data['image'] else "無")
        print("文章內容Base64長度:", len(article_data['description']))
        print("發佈日期:", article_data['held_date'])

        save_to_csv([article_data])
        print("CSV 已存檔：wechat_articles.csv")
    else:
        print("擷取失敗")


現想將此程式增加一項新功能，是讀取文件夾內所有CSV檔案內的URL欄位(假設在第二欄)作為程式中要讀取的文章，然後將所有輸出儲存在單一CSV內，以免儲存過程中出現中斷情況，應在每次寫入一行記錄後儲存才繼續。