python
1 2###spreadsheet読み込み 3import json 4import gspread 5from oauth2client.service_account import ServiceAccountCredentials 6 7scope = ['https://spreadsheets.google.com/feeds', 8 'https://www.googleapis.com/auth/drive'] 9 10credentials = ServiceAccountCredentials.from_json_keyfile_name('**.json', scope) 11gc = gspread.authorize(credentials) 12wks = gc.open('5ちゃん速報').sheet1 #シート指定 13 14###読み取り 15 16import requests 17from bs4 import BeautifulSoup 18 19load_url = "http://2ch-ranking.net/index.html?board=mnewsplus" 20html = requests.get(load_url) 21soup = BeautifulSoup(html.content,"html.parser") 22 23 24row=0 25for element in soup.find_all("tr"): 26 row +=1 27 wks.update_acell("A"+str(row),element.text) 28
Python初心者です。表題の件で、行き詰まっております。
勢いスレ「http://2ch-ranking.net/index.html?board=mnewsplus」のランキング
TOP10のみをGoogleSpareadSheetに書き込みたいと思っております(さらに、これを1時間ごとに更新していきたいと考えております。)。
現状だと、A1から一行ずつ、100位まですべて書き込まれ、gspreadのエラーコード400が出て
「exceeds grid limits」になってしまいます。
if文をforのなかに入れて、ためしたもののうまく行かず・・・解決方法(参考URLだけでもOKです)
を教えていただければと思っております。
何卒よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。