输入数据并迭代以在网页上抓取信息

enter data and iterate to scrape information on a webpage

我正在尝试使用 python 抓取此网站。

https://solanamonkey.business/search

我 运行 遇到问题我想遍历在搜索字段中输入的 1-5000 并将显示的数据抓取到 .CSV

对最佳方法有什么建议吗?

有一个直接的 url 来获取这个:

import requests
import pandas as pd

rows = []
for i in range(1,5001):
    url = 'https://solanamonkey.business/.netlify/functions/fetchSMB?id=%s' %i
    jsonData = requests.get(url).json()
    
    title = jsonData['nft']['id']
    row = {'id':title}
    for each in jsonData['nft']['attributes']['attributes']:
        row.update({each['trait_type']: each['value']})
    rows.append(row)

    print('ID: ', title)

df = pd.DataFrame(rows)   
df.to_csv('file.csv', index=False)