I'm currently working on a selenium bot that gets a random english noun from a list of 1000 nouns, puts it in a site that gets similar instagram tags, then goes on instagram, logs into my account, and starts liking pictures with that hashtag, then starts the process all over again
My problem is the function that returns similar hashtags, this is the code for it:
def get_similar_tags(tag):
url = "https://top-hashtags.com/hashtag/" + str(tag).lower() + "/"
page = requests.get(url).text
parsed_page = BeautifulSoup(page, "html.parser")
parsed_page = parsed_page.find("div", class_="tht-tags")
text = parsed_page.text
hashtag = text.split(" ")
hashtag = [s.strip('#') for s in hashtag]
hashtag = hashtag.pop(len(hashtag) - 1)
return hashtag
When i try to print the hashtag variable inside of the function, then the output is filled with hashtags, which is exactly what i need.
When i use the function to assign the hashtag variable to another variable, like this:
foo = get_similar_tags(random_noun)
and then i do
print(foo)
i get absolutely nothing, not even an empty list, just an empty line. i've already tried assigning the value returned by the get_similar_tags function using a global variable, but that doesn't work either.
Any help would be really apprecciated, Thanks