Skip to content

Commit

Permalink
fix 3
Browse files Browse the repository at this point in the history
  • Loading branch information
nishio committed Mar 23, 2023
1 parent 8f54713 commit 53eeb19
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
dist_stats = f"./{project}/stats/pages.json"
dist_data = "./data.json"

URL_TEMPLATE = "https://scrapbox.io/api/pages/{project}"
URL_TEMPLATE = f"https://scrapbox.io/api/pages/{project}"
LIMIT_PARAM = 1000


Expand All @@ -21,12 +21,12 @@ async def fetch(url):


async def main():
pages_response = await fetch(f"{URL_TEMPLATE}/{project}/?limit=1")
pages_response = await fetch(f"{URL_TEMPLATE}/?limit=1")
page_num = pages_response["count"]
max_index = (page_num // LIMIT_PARAM) + 1

pages = []
tasks = [fetch(f"{URL_TEMPLATE}/{project}/?limit={LIMIT_PARAM}&skip={index * LIMIT_PARAM}")
tasks = [fetch(f"{URL_TEMPLATE}/?limit={LIMIT_PARAM}&skip={index * LIMIT_PARAM}")
for index in range(max_index)]
for task in asyncio.as_completed(tasks):
result = await task
Expand All @@ -49,7 +49,7 @@ async def main():
f"[scrapbox-external-backup] Start fetching {i} - {i + skip} pages.")

urls = [
f"{URL_TEMPLATE}/{project}/{quote(title.title, safe='')}" for title in titles[i:i+skip]]
f"{URL_TEMPLATE}/{quote(title.title, safe='')}" for title in titles[i:i+skip]]
tasks = [fetch(url) for url in urls]
for j, task in enumerate(asyncio.as_completed(tasks), start=i):
print(
Expand Down

0 comments on commit 53eeb19

Please sign in to comment.