Skip to content

Instantly share code, notes, and snippets.

rank,installs
1,5000000
1,5000000
1,5000000
1,5000000
1,5000000
1,5000000
1,5000000
1,5000000
9,4000000
import requests
import os
import json
import pickle
def create_url(pagination_token,username):
# Specify the usernames that you want to lookup below
query = "to:" + username + "is:reply"
# You can enter up to 100 comma-separated values.
import requests
from bs4 import BeautifulSoup
# see this gist https://gist.github.com/jakobgreenfeld/232ddb7894994fae9390f1cba1a73357
import readsavedata
page = requests.get("https://www.community-finder.co/")
soup = BeautifulSoup(page.content, 'html.parser')
links = soup.find_all("a", class_="community-wrap", href=True)
# An example to get the remaining rate limit using the Github GraphQL API.
import datetime
import requests
import time
## see this gist https://gist.github.com/jakobgreenfeld/232ddb7894994fae9390f1cba1a73357
import readsavedata
headers = {"Authorization": "Bearer INSERT_DEVELOPER_TOKEN"}
# the GraphQL query parameter "website" returns for posts something like "https://www.producthunt.com/r/e49de0c9ba36cf?utm_campaign=producthunt-api&utm_medium=api-v2&utm_source=Application%3A+Dead+Products+%28ID%3A+39914%29"
# the following python script turns it into a proper url
import requests
def unshorten_url(url):
return requests.head(url, allow_redirects=True).url.replace("?ref=producthunt","")
ur = "https://www.producthunt.com/r/e49de0c9ba36cf?utm_campaign=producthunt-api&utm_medium=api-v2&utm_source=Application%3A+Dead+Products+%28ID%3A+39914%29"
@jakobgreenfeld
jakobgreenfeld / gist:232ddb7894994fae9390f1cba1a73357
Last active October 9, 2020 12:59
save and read data to csv files using python
import io
import csv
# reads data from csv file
def read_data(filename):
list = []
with open(filename, encoding="utf-8") as csvDataFile:
csvReader = csv.reader(csvDataFile)
for row in csvReader:
@jakobgreenfeld
jakobgreenfeld / gist:e43f8d98c6c5b3f096f3a0ed4c14610f
Last active October 9, 2020 13:42
Get Top Posts using Product Hunt GraphQL API v2
import requests
headers = {"Authorization": "Bearer INSERT_DEVELOPERTOKEN"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.producthunt.com/v2/api/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
return request.json()
else:
# Here's a minimal functioning example of how to use the producthunt GraphQL API using python.
# make sure to insert your own Developer Token, which you can get in the here https://www.producthunt.com/v2/oauth/applications
# to access different data, you need to change the query below. you can test queries in the API explorer https://ph-graph-api-explorer.herokuapp.com/
# lots of further details on queries can be found here http://api-v2-docs.producthunt.com.s3-website-us-east-1.amazonaws.com/object/viewer/#user
import requests
headers = {"Authorization": "Bearer YourDeveloperToken"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.