Created
February 3, 2021 01:46
-
-
Save DerekHawkins/62e910d1ad4b21d2d1ac7644af3e0c2f to your computer and use it in GitHub Desktop.
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
term = input('What keyword would you like to explore?') | |
df1 = pd.DataFrame(parse_response(requests.get(build_seo_urls(phrase=term)).content)) | |
try: | |
keyword_list = secondary_layer(crawl_urls=df1['Url']) | |
except KeyError as e: | |
raise Exception("The keyword you have inputted is either not in SEMrush's database or your input was incorrectly submitted. Please rerun and try again.") | |
third_layer = third_layer_setup(second_layer_kw=keyword_list) | |
third_layer = third_layer.merge(keyword_list[['Keyword','Search Volume', 'CPC', 'Competition']], on="Keyword", how='left') | |
third_layer = third_layer.sort_values(by='Occurance', ascending=False) | |
third_layer.drop_duplicates(inplace=True) | |
third_layer = third_layer.reset_index(drop=True) | |
third_layer = third_layer[['Keyword', 'Search Volume', 'CPC', 'Competition', 'Occurance']] | |
third_layer['Competition'] = third_layer['Competition'].astype(float) | |
# Document how many keywords were found | |
print(f'There were {third_layer.shape[0]} relevant keywords collected.') | |
third_layer.to_csv(f'{term}.csv', index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment