Skip to content

Commit

Permalink
update api
Browse files Browse the repository at this point in the history
  • Loading branch information
LyleMi committed Jun 14, 2020
1 parent df36ea0 commit fc87bf5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
33 changes: 33 additions & 0 deletions saker/api/fofa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json
import requests

from saker.utils.encode import b64e


class Fofa(object):

url = "https://fofa.so/api/"

def __init__(self, email, key):
super(Fofa, self).__init__()
self.s = requests.Session()
self.email = email
self.key = key

def search(self, query, page=1, size=100, full="false"):
qbase64 = b64e(query)
api = "v1/search/all"
params = {
"qbase64": qbase64,
"page": page,
"size": size,
"full": full,
"email": self.email,
"key": self.key,
}
r = self.s.get(self.url + api, params=params)
data = json.loads(r.text)
return data
10 changes: 0 additions & 10 deletions saker/api/githubapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,3 @@ def gatherParameter(self):
for parameter in datas:
print(parameter)
parameters[parameter] += 1
break


if __name__ == '__main__':
token = ''
g = GithubAPI(token)
# print(g.gatherByEmail('@github.com'))
# g.gatherParameter()
# g.getUsersByOrgContributors('')
# g.dumpUsersInfo()
21 changes: 21 additions & 0 deletions test/api/githubapi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import unittest

from saker.api.githubapi import GithubAPI


class GithubTest(unittest.TestCase):

def test_main(self):
token = ''
g = GithubAPI(token)
print(g.gatherByEmail('@github.com'))
# g.gatherParameter()
# g.getUsersByOrgContributors('')
# g.dumpUsersInfo()


if __name__ == '__main__':
unittest.main()

0 comments on commit fc87bf5

Please sign in to comment.