ページをリクエストするたびに、json形式でJavaScriptによって取得されます。このように「https://www.kaggle.com/kernels.json?sortBy=hotness&group=everyone&pageSize=20&after=439354&language=all&outputType=all」から取得できます。
import requests
import json
source = requests.get("https://www.kaggle.com/kernels.json?sortBy=hotness&group=everyone&pageSize=20&after=439354&language=all&outputType=all")
json_obj = source.json()
for a in json_obj:
print (a["title"])
出力:
2004-2005 Landfalling Hurricanes animation
Visualization of StockData
Generating Sentences One Letter at a Time
Decoding the Sexiest Job of 21st Century!!
Novice to Grandmaster
Analysis on Pokemon Data
ROC Curve with k-Fold CV
Japan Bulgaria trade playground
Bootstrapping and CIs with Veteran Suicides
Replicating "Did I do that?" paper analyses with R
Social Progress Index and World Happiness Report
SVM+HOG On ColourCompositeImage
Low- level students
PyTorch Speech Recognition Challenge (WIP)
Loans -getting Insights
Exploring Youtube Trending Statistics EDA
3 Simple Steps (LB: .9878 with new data)
Titanic: Neural Network using Keras
Feature Engineering
Why do employees leave and what to do about it
あなたは変更する必要があります唯一の事は、私のリクエストで439354だった「後」クエリ文字列パラメータですが、あなたが最初のレコードを取得するために0に設定することができ。
"pageSize"クエリ文字列パラメータを変更することによって返されるレコードの量を変更することもできます。 「https://www.kaggle.com/kernels.json?sortBy=hotness&group=everyone&pageSize=5&after=0&language=all&outputType=all」
出力:
Data ScienceTutorial for Beginners
Data visualization and investigation
Spooky NLP and Topic Modelling tutorial
20 Years Of Games Analysis
NYC Taxi EDA - Update: The fast & the curious
それともurllibは持つ例:
import urllib.request
import json
kaggle = "https://www.kaggle.com/kernels.json?sortBy=hotness&group=everyone&pageSize=5&after=0&language=all&outputType=all"
data = urllib.request.urlopen(kaggle).read()
json_obj = json.loads(data.decode("utf-8"))
for a in json_obj:
print (a["title"])
は、それが静的なコンテンツの解析のために使用されるHTMLコンテンツは、urllibはない取得するための時間遅延し、使用要求のライブラリを与えますあなたのケースは動的コンテンツです –
[HTMLデータはurllibから隠されている可能性があります](https://stackoverflow.com/questions/47351045/html-data-is-hidden-from-urllib) –