piplcom / piplapis-python Goto Github PK
View Code? Open in Web Editor NEWPython client library for Pipl's APIs
License: Other
Python client library for Pipl's APIs
License: Other
The code for send()
incorrectly assumes that all errors from the Pipl API are JSON, and attempts to decode them, which leads to a further exception, and a verbose exception chain.
Due to this, the caller doesn't receive an exception, and the SearchAPIResponse
object is returned as if nothing bad happened, with critical fields such as http_status_code
set to None
.
It should check if the response is in JSON before attempting to decode it.
Example exception:
ERROR:root:HTTPError: Error fetching data from Pipl
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/piplapis/search.py", line 341, in send
exception = SearchAPIError.from_json(json_error.decode())
File "/usr/local/lib/python3.6/site-packages/piplapis/data/utils.py", line 127, in from_json
d = json.loads(json_str)
File "/usr/local/lib/python3.6/json/__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.6/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.6/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/code/syncme/integrations/pipl/search.py", line 440, in __query_pipl
response = request.send()
File "/usr/local/lib/python3.6/site-packages/piplapis/search.py", line 345, in send
raise e
File "/usr/local/lib/python3.6/site-packages/piplapis/search.py", line 331, in send
response = urllib2.urlopen(request)
File "/usr/local/lib/python3.6/urllib/request.py", line 223, in urlopen
return opener.open(url, data, timeout)
File "/usr/local/lib/python3.6/urllib/request.py", line 532, in open
response = meth(req, response)
File "/usr/local/lib/python3.6/urllib/request.py", line 642, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/local/lib/python3.6/urllib/request.py", line 570, in error
return self._call_chain(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 504, in _call_chain
result = func(*args)
File "/usr/local/lib/python3.6/urllib/request.py", line 650, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 502: Bad Gateway
When attempting to use SearchAPIResponse.from_dict, if a date value contains a time it fails. The source of the error is in util.py line 60. I fixed the error by defining:
TIMESTAMP_FORMAT_WITH_TIME = '%Y-%m-%dT%H:%M:%S'
And changing line 60 to read
try:
return datetime.datetime.strptime(s, TIMESTAMP_FORMAT)
except ValueError:
return datetime.datetime.strptime(s, TIMESTAMP_FORMAT_WITH_TIME)
Not sure if that's the best solution but I've run into the error multiple times so I figured I'd report it.
I would assume that the list of parameters here (https://pipl.com/dev/reference/?python#using-search-parameters) would all be valid key word arguments to the SearchAPIRequest. However, user_id is not supported, nor is zip code or phone.
It should be noted that using a manual PIPL api URL such as api.pipl.com/search?user_id=abcd@facebook works in a web browser, so user_id should be an allowable kwarg for the SearchAPIRequest, no?
Hi guys,
I would be great if you can port the code to python 3.4 and above.
Thanks.
person = Person()
person.names.append(Name(first='Thalia'))
request = SearchAPIRequest(api_key='SECRET', person=person)
response = request.send()
File "", line 1, in
File "/root/PythonProjects/venv/lib/python3.5/site-packages/piplapis/search.py", line 315, in send
self.validate_query_params(strict=strict_validation)
File "/root/PythonProjects/venv/lib/python3.5/site-packages/piplapis/search.py", line 255, in validate_query_params
raise ValueError('Some fields are unsearchable: %s' % self.person.unsearchable_fields)
ValueError: Some fields are unsearchable: [Name(first='Thalia')]
I am always getting response as empty
Below is the code for reference
from piplapis.search import SearchAPIRequest
from piplapis.data import Person, Name, Address, Job
from piplapis.search import SearchAPIError
request = SearchAPIRequest(raw_name=u'Bill Gates', api_key='zzzzz') // Not working
OR
request = SearchAPIRequest(first_name=u'Bill', last_name=u'Gates', api_key='ZZZZ') // Not working
try:
response = request.send()
except SearchAPIError as e:
print e.http_status_code, e
print(response.name)
print(response.gender)
print(response.education)
print(response.username)
print(response.address)
Anything wrong ?
piplapis/data/utils.py", "line": 168, "message": "year=1887 is before 1900; the datetime strftime() methods require year >= 1900", "exception": "exceptions.ValueError"
can we change datetime to use something else here?
Looks like a common problem with datetime function as you can not use year before 1900
I think all that's needed is
python setup.py register
python setup.py sdist
python setup.py upload
Hi,
Using python 3.4 with the latest piplapis version.
For a certain search I get a crash in:
File "/home/sivanr/env/lib/python3.4/site-packages/piplapis/data/available_data.py", line 17, in to_dict d['premium'] = self.premium.to_dict() File "/home/sivanr/env/lib/python3.4/site-packages/piplapis/data/available_data.py", line 84, in to_dict if getattr(self, child) > 0: TypeError: unorderable types: NoneType() > int()
I looked into this function for debug and found that in certain responses (not always) the result of getattr(self, child) returns None, hence the error message.
Please check if the problem is that a result of getattr is None or that this function should support this and check in advance.
The following regular expressions produce syntax warnings with Python 3.12:
piplapis/data/fields.py:398: SyntaxWarning: invalid escape sequence '\-'
re_email = re.compile("^[a-zA-Z0-9'._%\-+]+@[a-zA-Z0-9._%\-]+\.[a-zA-Z]{2,24}$")
piplapis/data/fields.py:576: SyntaxWarning: invalid escape sequence '\d'
tokens = ",".join([re.sub("&dsid=\d+", "", x.thumbnail_token) for x in images_with_tokens])
piplapis/data/utils.py:109: SyntaxWarning: invalid escape sequence '\:'
VALID_URL_REGEX = re.compile('^(?#Protocol)(?:(?:ht|f)tp(?:s?)\:\/\/|~\/|\/)?(?#Username:Password)(?:\w+:\w+@)?(?#Subdomains)(?:(?:[-\w]+\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\d]{1,5})?(?#Directories)(?:(?:(?:\/(?:[-\w~!$+|.,=]|%[a-f\d]{2})+)+|\/)+|\?|#)?(?#Query)(?:(?:\?(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)(?:&(?:[-\w~!$+|.,*:]|%[a-f\d{2}])+=?(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)*)*(?#Anchor)(?:#(?:[-\w~!$+|.,*:=]|%[a-f\d]{2})*)?$')
Since these are not valid string escape sequences, the \
should be escaped with another \
, or the whole string should be marked raw with r''
.
This used to be a DeprecationWarning
, and has now been upgraded to a SyntaxWarning
.
the send function does not allow for us to set our MITM proxy certificate bundle file.
piplapis-python/piplapis/search.py
Line 343 in f43c956
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.