This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ping the CVENT API and parse the JSON | |
# (sort in descending order to place the most recent registrants at the top of the JSON output | |
r = requests.get(f'https://api-platform.cvent.com/ea/attendees?sort=registeredAt:DESC', headers=call_headers) | |
frame = [] | |
for crawl in r.json()['data']: | |
_id = crawl['id'] | |
full_name = f"{crawl['contact']['firstName']} {crawl['contact']['lastName']}" | |
email_address = crawl['contact']['email'] | |
try: | |
company_name = crawl['contact']['company'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tqdm.notebook import tqdm | |
from time import sleep | |
import datetime | |
import requests | |
import base64 | |
import time | |
import os | |
import json | |
import googleanalytics as ga | |
import gspread_dataframe as gd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
# Import customer list for company match and employee list for department atribution | |
df_customer_list = pd.read_excel('---.xlsx', skiprows=10) | |
customers = df_customer_list[['Company']]['Company'].to_list() | |
employee_list = pd.read_excel('---.xlsx') | |
employee_list['Full Name'] = [f"{employee_list['First Name'][i]} {employee_list['Last Name'][i]}" for i in range(employee_list.shape[0])] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep | |
client = hubspot.Client.create(api_key="hubspot_api_key") | |
for i, s in tqdm(zip(main['id'], main['Schema'])): | |
blog_post = BlogPost(id=i, head_html=s) | |
try: | |
api_response = client.cms.blogs.blog_posts.blog_post_api.update(object_id=i, | |
blog_post=blog_post) | |
pprint(api_response) | |
except ApiException as e: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
main = pd.concat(mainframe) | |
main['Schema'] = None | |
for i in tqdm(range(0, len(main))): | |
main['Schema'][i] = f'<script type="application/ld+json">{SchemaBuild(main["author"][i], main["title"][i],main["url"][i], main["datePublished"][i], main["dateModified"][i], main["image"][i],main["description"][i])}</script>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Schema Build ### | |
def SchemaBuild(author, title, url, datePub, dateMod, image, des): | |
builder = SchemaBuilder() | |
builder.add_schema({"@type": "Article"}) | |
builder.add_schema({"publisher": {'@type':'Organization', | |
'name': 'Your Organization', | |
'logo':{ | |
'@type':'ImageObject', | |
'url':'example.com/image.png', # the URL of your logo | |
'width':'xxx', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hubspot | |
from hubspot.cms.blogs.blog_posts import BlogPost, ApiException | |
from genson import SchemaBuilder | |
import dateutil.parser as parser | |
import requests | |
import json | |
import pandas as pd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pivot = log_file.pivot_table(index='date', values='server_response', | |
aggfunc={'server_response':'count'}).rename(columns={'server_response':'crawls'}) | |
fig = go.Figure(data=go.Scatter(x=pivot.index, y=pivot.crawls, mode='lines')) | |
fig.update_layout(title='Crawl Rate: example.com', | |
xaxis_title='Date', | |
yaxis_title='Number of Pings by Search Engine') | |
fig.show() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pivot = log_file.pivot_table(index='request_type', values='server_response', | |
aggfunc={'server_response':'count'})\ | |
.sort_values(by='server_response', ascending=False).reset_index().\ | |
rename(columns={'request_type':'file_name', 'server_response':'number_of_pings'}) | |
fig = go.Figure(data=[go.Table( | |
header=dict(values=list(pivot.columns), | |
fill_color='blue', | |
font=dict(color='white', size=12), | |
align='left'), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objects as go | |
pivot = log_file.pivot_table(index='status_code', values='server_response', | |
aggfunc={'server_response':'count'}) | |
fig = go.Figure(data=[go.Pie(labels=pivot.index, values=pivot.server_response)]) | |
fig.show() |
NewerOlder