python - How can I use rapportive.py in django -
I am using my dragon project in Django. I am getting an error to enter text with import logging from
imports import docopt import docopt from Python-requests.org # Pylint From: disable = C0103 logger = logging.gatlogger (__name__) logger.Setelval (logging .info) # pylint: enabled = C0103 STATUS_URL = 'https://rapportive.com/login_status? User_email = {0} 'URL =' https://profiles.rapportive.com/contacts/email/{0} '# pylint: disabled = R0903 class profile (object): Profile object printing to collect profile profiles " "" Def __init__ (self, person): if person: self name = person.gate ('name') self.jobinfo = [(occupation.get ('job_title'), occupation.get ('company')) For the possession of the person. Gate ('business', [])] self subscribe. [[Membership.get (' site_name '), membership.jet (' profile_val ')) for membership to person. (' Member Ya ', [])] self.success = person.get (' success') def __str __ (self): return dedent ("" "name: {0} {1} {2}" "") format ( The name, "\ n" .joined ("{0} {1}" format for title (title, company), company in self.jobinfo), "\ n" for "site_name" for siteman Format (site_name, url), URL itself) .def request (e-mail): '' 'rapportive_request (email): sends a query to non-documentary spying API returns a' 'status' url = STATUS_URL .format (email) response = requests.get (status_url) .json () Response # error as ssion_token = response.get ('session_token') may fail with anger if 'error' in response: 'response' ['error'] elif feedback ['condition'] == 200 and session_token : Logger.debug ('session token: {0}'. Format (session_token) url = URL.format (email) header = {'X-session-token': session_token} response = requests.get (url, headers = headers) .json () if feedback.get ('success' )! = 'None_useful': return profile (response.get ('contact')) {} def ___ process_email (email, output_file = none) returns: "profile profile = request (email) if found in profile" and "profile" .success! = 'Nothing_useful': found form for logger.info ('{0}'. (Email)) print (profile) if output_file: output_file.write (summary + '\ n') Other: print ( "No information was found \ n") DEIF Main (): '' 'Main: Expect a list of email addresses via STDI and answer Checkable API '' 'options = docopt (__doc__, version = "0.1.0") Logging.basicConfig (format ='% (asctime) s% (name) -12s% (levelname) -8s% (message) s , Datefmt = '% m-% d% H:% M') If the option ["-Webows"]: logger. STL Evel (logging.DEBUG) email = options.get ("- email") args = [email] If output = line.rstrip ()) for line in else.ystem.setdin output = options.get ("- output") arguments in output = output and open (output, "w"): ___ process_email ( Arg, output) if __name__ == '__main__': main ()
this is my Working on the machine.
Just a few things:
-
import request
unavailable - define the
summary
variable in the ___ process_mail function I think this is an error in the indentationreturn profile (response.get ('contact')
summary = str (profile)
- < / Li>
You get your error form request
function, if response.get ('success')! = 'Nothing'
Should always lie.
Have you seen it - a There are some examples and some emails that can be used.
I did use this one. I get a result jmwright798@gmail.com
Comments
Post a Comment