Created
October 13, 2014 12:54
-
-
Save rsadwick/47c188dc2df1d026896d to your computer and use it in GitHub Desktop.
snags related hash tags based on query
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 urllib2 | |
from bs4 import BeautifulSoup | |
site_url = 'https://ritetag.com/best-hashtags-for/' | |
hash_tag = raw_input() | |
response = urllib2.urlopen(site_url + hash_tag) | |
html = response.read() | |
soup = BeautifulSoup(html) | |
def match_class(target): | |
def do_match(tag): | |
classes = tag.get('class', []) | |
return all(c in classes for c in target) | |
return do_match | |
tags = soup.find_all(match_class(["tag"])) | |
for spans in tags: | |
print spans.text | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment