Last active
June 12, 2020 01:39
-
-
Save bertrandmartel/196db3a722023ff24aee18a290890612 to your computer and use it in GitHub Desktop.
kickstarter graphql api - https://stackoverflow.com/questions/62335537/scraping-text-from-kickstarter-projects-return-nothing/62336107#62336107
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
s = requests.Session() | |
r = s.get("https://www.kickstarter.com") | |
soup = BeautifulSoup(r.text, 'html.parser') | |
xcsrf = soup.find("meta", {"name": "csrf-token"})["content"] | |
query = """ | |
query GetEndedToLive($slug: String!) { | |
project(slug: $slug) { | |
id | |
deadlineAt | |
showCtaToLiveProjects | |
state | |
description | |
url | |
__typename | |
} | |
}""" | |
r = s.post("https://www.kickstarter.com/graph", | |
headers= { | |
"x-csrf-token": xcsrf | |
}, | |
json = { | |
"query": query, | |
"variables": { | |
"slug":"kuhkubus-3d-escher-figures" | |
} | |
}) | |
print(r.json()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment