【问题标题】:I have managed to get data writing into Google Sheets but I would like to be able to 'overwrite' the data rather than 'insert_row'我已设法将数据写入 Google 表格,但我希望能够“覆盖”数据而不是“插入行”
【发布时间】:2020-12-28 17:14:53
【问题描述】:

我尝试执行“update_row”时遇到的错误如下:

AttributeError: 'Worksheet' 对象没有属性 'update_row'

这是我的代码:

listing = soup.find_all('div', 'result-contain')
for details in listing:
title = details.find('h3')
if not title:
    continue
title = title.text.strip()[0:28]
price = details.find('div', 'price')
mileage = details.find_all('li')[0]
just_miles = mileage.text.split()
miles = just_miles[:-1]
adjusted_miles = str(miles)[1:-1]
adjusted_miles = adjusted_miles.replace("'", "")
link = details.find('a')

print(title, price.text, adjusted_miles, link['href'])
index = 2
row = [title,price.text,adjusted_miles,link['href']]
sheet1.insert_row(row,index)

请问艾米有什么想法?

【问题讨论】:

    标签: python web-scraping google-sheets beautifulsoup gspread


    【解决方案1】:

    gspread没有update_row方法,你一定在找worksheet.update()方法。

    提示:您可以使用python的dir()方法查看指定对象的所有属性和方法。

    这个例子来自 gspread 工作表对象:

    参考:

    gspread Documentation

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-08-30
      • 2012-02-07
      • 2015-07-11
      • 1970-01-01
      • 2015-10-20
      • 2022-12-05
      • 1970-01-01
      • 2017-09-19
      相关资源
      最近更新 更多