我当前的代码将 CSV 写入多个单元格(请参阅屏幕截图)

from bs4 import BeautifulSoup
import csv
import urllib
url = 'https://www.bhphotovideo.com/c/product/1346734-REG/canon_eos_6d_mark_ii.html'
page = urllib.request.urlopen(url)
soup = BeautifulSoup(page,'lxml')
content = soup.find('div', class_='js-productHighlights product-highlights c28 fs14 js-close')
bullets = content.find_all('li', class_='top-section-list-item')
csv_file = open('book2.csv', 'w')
csv_writer = csv.writer(csv_file)
csv_writer.writerow (['headline'])
for bullet in bullets:
headline = (bullet.string)
csv_writer.writerow ([headline])
csv_file.close()
如何将excel写入单个单元格?
所需的输出将是 - 单元格 A1 将包含变量“标题”包含的所有文本。
慕的地6264312
呼啦一阵风
随时随地看视频慕课网APP
相关分类