def test_linkedin_basic(self): self.start() fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") token = self.get_access_token() if token is None: warnings.warn("no credential, unable to test linkedin") return linkedin = LinkedInAccess(*token) res = linkedin.connect(False) fLOG("***", res) try: prof = linkedin.get_profile() except Exception as e: if "Expired access token." in str(e): warnings.warn(str(e)) return else: raise e fLOG("prof", prof) assert prof["lastName"] == "Dupre" fLOG("------") prof = [] se = linkedin.search_profile( params={ "last-name": "dupre", "first-name": "xavier"}) for _ in se["people"]["values"]: fLOG(_) assert 'id' in _ try: prof.append(linkedin.get_profile(id=_['id'])) except Exception as e: fLOG("error", e) fLOG("----") assert len(se["people"]["values"]) > 1 assert len(prof) > 0 for p in prof: fLOG(p)
def test_linkedin_search_key(self): self.start() fLOG( __file__, self._testMethodName, OutputPrint=__name__ == "__main__") token = self.get_access_token() if token is None: warnings.warn("no credential, unable to test linkedin") return linkedin = LinkedInAccess(*token) res = linkedin.connect() if __name__ == "__main__": if False: for year in range(2010, 2014): fLOG("**** year ", year) se = linkedin.search_profile( params={"keywords": "ensae %d" % year}, count=-1, as_table=True) if se is not None: temp_file = os.path.abspath( os.path.join( os.path.split(__file__)[0], "temp_ensae_%d.txt" % year)) fLOG("writing ", len(se)) se.save(temp_file, encoding="utf8") se = linkedin.search_profile( params={"keywords": "ensae"}, count=-1, as_table=True) temp_file = os.path.abspath( os.path.join( os.path.split(__file__)[0], "temp_ensae2.txt")) fLOG("writing ", len(se)) se.save(temp_file, encoding="utf8") if True: for key in "new-york paris londres singapour montreal pekin shangai tokyo kyoto san francisco boston bank research economy statistics insurance".split(): fLOG("**** key ", key) se = linkedin.search_profile( params={"keywords": "ensae %s" % key}, count=-1, as_df=True) if se is not None: temp_file = os.path.abspath( os.path.join( os.path.split(__file__)[0], "temp_ensae_%s.txt" % key)) fLOG("writing ", len(se)) se.save(temp_file, encoding="utf8") else: fLOG("***", res) try: prof = linkedin.get_profile() except Exception as e: if "Expired access token." in str(e): return else: raise e fLOG("prof", prof) assert prof["lastName"] == "Dupre" fLOG("------") prof = [] se = linkedin.search_profile( params={ "keywords": "ensae"}, as_table=True) fLOG(se) assert "headline" in se.header assert len(se) > 0