import json
import urllib
import sqlite3
def loading():
url = 'https://jobs.github.com/positions.json?page=1' # URL for API 1-5json_obj = urllib.urlopen(url)
response = urllib.urlopen(url)
data = json.load(response) # loads the url and set it into data variable
for item in data[0].keys():
return data # Get the keys
# def loading():
# print " LOADING API(s)"
# urllib.urlopen('https://jobs.github.com/positions.json?page=1')
# temp = json.dumps(data[1])
# print (json.dumps(data[1]))
# print (" ")
def createDB(data):
conn = sqlite3.connect('comp.db')
c = conn.cursor()
# Create table
c.execute('''CREATE TABLE IF NOT EXISTS comp
(id text primary key, type text, url text,created_at timestamp, company text, company_url text, location text, title text, description text, how_to_apply text, company_logo text
)''')
temp_values = list(tuple())
for item in data:
list_of_values = [v for k, v in item.items()]
tuple_of_values = tuple(list_of_values)
temp_values.append(tuple_of_values)
#TO DO
# Make sub sets for each category call
# put in category for each ? in table
c.executemany('INSERT INTO comp VALUES (?,?,?,?,?,?,?,?,?,?,?)', temp_values)
conn.commit()
def main():
data = loading()
createDB(data)
main()
Я получаю эту ошибку компиляции
Traceback (most recent call last):
File "/Users/issac_rodriguez/PycharmProjects/N/Sprint2/database.py", line 43, in <module>
main()
File "/Users/issac_rodriguez/PycharmProjects/N/Sprint2/database.py", line 40, in main
data = loading()
File "/Users/issac_rodriguez/PycharmProjects/N/Sprint2/database.py", line 9, in loading
data = json.load(response) # loads the url and set it into data variable
AttributeError: 'module' object has no attribute 'load'