【发布时间】:2021-05-26 13:23:10
【问题描述】:
我正在尝试抓取网站:https://gmatclub.com/forum/decision-tracker.html 我需要获取决策跟踪表 - 实时更新。下面的代码提供了当前页面中的数据。
当您向下滚动时,会有一个“显示更多”按钮,可以显示旧条目。从表中获取所有数据的方法是什么。 (所有 5500 多个条目)
import requests
import pandas as pd
with requests.Session() as connection:
connection.headers.update(
{
"referer": "https://gmatclub.com/forum/decision-tracker.html",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.86 YaBrowser/21.3.0.740 Yowser/2.5 Safari/537.36",
}
)
_ = connection.get("https://gmatclub.com/forum/decision-tracker.html")
endpoint = connection.get("https://gmatclub.com/api/schools/v1/forum/app-tracker-latest-updates?limit=50&year=all").json()
for item in endpoint["statistics"]:
print(item)
#df = pd.DataFrame(endpoint["statistics"])
#print(df.head())
#df.to_csv("your_table_data.csv", index=False)
【问题讨论】:
标签: python web-scraping python-requests xmlhttprequest