Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- import logging
- import requests
- import json
- import dateutil.parser
- import datetime
- import re
- from requests.adapters import HTTPAdapter
- from requests.packages.urllib3.util.retry import Retry
- http = requests.Session()
- logging.basicConfig(level=logging.DEBUG)
- retries = Retry(total=5, backoff_factor=2, status_forcelist=[ 502, 503, 504, 429, 403])
- http.mount('https://', HTTPAdapter(max_retries=retries))
- headers = {
- "Accept": "application/vnd.bountysource+json; version=1",
- "Accept-Encoding": "gzip, deflate, br",
- "Accept-Language": "en-US,en;q=0.9",
- "Cache-Control": "no-cache",
- "Connection": "keep-alive",
- "Host": "api.bountysource.com",
- "Origin": "https://www.bountysource.com",
- "Pragma": "no-cache",
- "Referer": "https://www.bountysource.com/",
- "Sec-Fetch-Dest": "empty",
- "Sec-Fetch-Mode": "cors",
- "Sec-Fetch-Site": "same-site",
- }
- #print(http.get('https://api.bountysource.com/search/bounty_search?callback=CORS&order=earliest_bounty&page=2&per_page=250', headers=headers).text)
- regex = re.compile(r"\)\w*$")
- def clean_json(x):
- x = x.replace('CORS(', '')
- x = x.replace(")\n", '')
- x = x.replace('/**/ ', '')
- x = regex.sub('', x)
- return x
- TWO_YEARS = 365 * 2
- total = 0
- bounties = 0
- page = 0
- now = datetime.datetime.now()
- while True:
- url = "https://api.bountysource.com/search/bounty_search?callback=CORS&direction=asc&order=earliest_bounty&page=%s&per_page=250" % (page)
- text = clean_json(http.get(url, headers=headers).text)
- for issue in json.loads(text)['data']['issues']:
- #print(issue)
- then = dateutil.parser.isoparse(issue['created_at']).replace(tzinfo=None)
- #print((now-then).days)
- if (now - then).days > TWO_YEARS and issue['paid_out'] is False:
- total += float(issue['bounty_total'])
- bounties += 1
- page += 1
- print(total)
- print(bounties)
Add Comment
Please, Sign In to add comment