在python中,每个URL仅获得1个结果(最后一个结果),而不是每个URL获得60个结果

在python中,每个URL仅获得1个结果(最后一个结果),而不是每个URL获得60个结果

编码此给定的打击 修复后的代码应该是什么?

这是python代码

from bs4 import BeautifulSoup as soup
from concurrent.futures import ThreadPoolExecutor
import requests

page_url = "url.xml"
number_of_threads = 6
out_filename = "title.csv"
headers = "title,brand,category \n"

def extract_data_from_url_func(url):
    print(url)
    response = requests.get(url)
    page_soup = soup(response.text, "html.parser")

    containers = page_soup.findAll('div',{'class' : 'column column-block block-grid-large single-item'})

    for container in containers:

        title = container['data-name'].replace(",", "|")
        brand = container['data-brand-name']
        category = container['data-category-name'].replace(",", "|")

        output_list = [title,brand,category]
        output = ",".join(output_list)
        print(output)
        return output

with open("url.xml", "r") as fr:
    URLS = list(map(lambda x: x.strip(), fr.readlines()))

with ThreadPoolExecutor(max_workers=number_of_threads) as executor:
    results = executor.map( extract_data_from_url_func, URLS)
    responses = []
    for result in results:
        responses.append(result)


with open(out_filename, "w", encoding='utf-8-sig') as fw:
  fw.write(headers)
  for response in responses:
      fw.write(response + "\n")