def linkedin_setup(): start_time = datetime.now() linkedin_object = get_linkedin_object() user_input = input("Enter the name of company or type 'exit' to exit: ").strip() company_universal_name = get_company_name(user_input) get_linkedin_id(company_universal_name, linkedin_object=linkedin_object) print(f"Total Time={datetime.now() - start_time}") print("=" * 160) return linkedin_setup()
def get_engagements(linkedin, company, total_likes=0, total_posts=0): company_universal_name = get_company_name(company) print(f"Looking engagements for : {company_universal_name}") company_updates = get_updates( linkedin_object=linkedin, company_name=company_universal_name ) if company_updates: for post in company_updates: post_link, post_like = get_post_link_and_social_activity(item=post) total_likes += post_like total_posts += len(company_updates) return total_posts, total_likes else: print("Company doesnt have any post and likes!!") return None, None
def linkedin_posts_setup(): start_time = datetime.now() linkedin_object = get_linkedin_object() print("=" * 160) user_input = input( "Enter the company universal name or urn id or linkedin profile url or type exit: " ).strip() if user_input == EXIT: sys.exit("Quiting the Tool!!") company_universal_name = get_company_name(user_input) print("Looking for posts: ....") company_updates = get_updates( linkedin_object=linkedin_object, company_name=company_universal_name ) if company_updates: print("Fetched the posts and now printing them :") for update_number, update in enumerate(company_updates): print_linkedin_post_data(item_number=update_number, item=update) print(f"Total Time={datetime.now() - start_time}") linkedin_posts_setup()
def id_html_table(): start_time = datetime.now() company_identifier = request.args.get("company") company = get_company_name(input_string=company_identifier) df_ids = get_linkedin_id(company_name=company, linkedin_object=linkedin_object) print(f"Time taken to fetch the result= {datetime.now() - start_time}") print("=" * 130) return render_template( "simple.html", page_title=f"IDs for {company}", tables=[ df_ids.to_html( classes=["table-bordered", "table-striped", "table-hover"], justify="initial", render_links=True, escape=False, float_format="{:,.0f}".format, ) ], titles=df_ids.columns.values, )
def posts_html_table(): start_time = datetime.now() company_identifier = request.args.get("company") company = get_company_name(input_string=company_identifier) company_updates = get_updates(linkedin_object=linkedin_object, company_name=company) if not company_updates: return f"No post for :{company_identifier}" df_post = pd.DataFrame() for update in company_updates: linkedin_post_link, total_likes = get_post_link_and_social_activity( item=update) shared_url = get_url(item=update) df_post = df_post.append( { "LinkedIn Post Url": linkedin_post_link, "Total Likes": total_likes, "Shared Url": shared_url, }, ignore_index=True, ) print(f"Time taken to fetch the result= {datetime.now() - start_time}") print("=" * 130) return render_template( "simple.html", page_title=f"Posts for {company}", tables=[ df_post.to_html( classes=["table-bordered", "table-striped", "table-hover"], justify="initial", render_links=True, escape=False, float_format="{:,.0f}".format, ) ], titles=df_post.columns.values, )