Created
July 29, 2019 11:56
-
-
Save DerekHawkins/fe359efb01f25c6a274e8b1568e4383a to your computer and use it in GitHub Desktop.
This file contains 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
service_url = 'https://api.semrush.com/analytics/v1/' | |
def backlink_url_build(): | |
params = { | |
"?type": "backlinks", | |
'key': api_key, | |
'target': "clientsite.com", | |
'target_type': 'root_domain', | |
'display_limit': '30000', | |
'display_sort': 'first_seen_desc' | |
} | |
data = urllib.parse.urlencode(params, doseq=True) | |
main_call = urllib.parse.urljoin(service_url, data) | |
main_call = main_call.replace(r'%3F', r'?') | |
return main_call | |
bl_call = backlink_url_build() | |
bl_data_set = API_Call(url=bl_call) | |
df_bl = pd.DataFrame(bl_data_set) | |
time_bar = [] | |
for time_change in df_bl['first_seen']: | |
new_time = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(int(time_change))) | |
time_bar.append(new_time) | |
df_bl['first_seen'] = time_bar | |
new_bl = df_bl[df_bl['first_seen'].str.contains(time_check)] | |
new_bl['page_score'] = new_bl['page_score'].astype(int) | |
new_bl = new_bl[new_bl['page_score'] > 20] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment