Beispiel #1
0
    def test_sightings(self):

        if python_version == 3:
            key = input("Testing Sightings: What's your API Key?\n")
        elif python_version == 2:
            key = raw_input("What's your API Key?\n")

        hatebase = HatebaseAPI({"key": key, "debug": False})
        filters = {
            'is_about_nationality': '1',
            'language': 'eng',
            'country_id': 'US'
        }
        output = "json"
        # get sightings
        response = hatebase.getSightings(filters=filters, format=output)
        # get some details from response
        results = response["number_of_results"]
        pages = response["number_of_pages"]

        if hatebase.debug == True:
            print(response)
        self.assertEqual(response["token"], hatebase.token)
        self.assertTrue(int(pages) > 500)
        self.assertTrue(int(results) > 54239)
Beispiel #2
0
import json
import requests
from hatebase import HatebaseAPI

key = "TuwmngrrxcytZkgqyfvtpdUb4yjsKsru"

hatebase = HatebaseAPI({"key": key})
filters = {
    'is_about_nationality': "false",
    'is_about_ethnicity': "false",
    'is_about_religion': "false",
    'is_about_gender': "false",
    'is_about_sexual_orientation': "false",
    'is_about_disability': "false",
    'is_about_class': "true",
    'language': 'ENG',
    'country': 'US',
    'year': "2015"
}
format = "json"
json_response = hatebase.getSightings(filters=filters, format=format)

with open('classOnly2015.txt', 'w+') as outfile:
    outfile.write(json.dumps(json_response, indent=4))