Skip to content

Instantly share code, notes, and snippets.

@ShaikeA
Last active January 13, 2019 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShaikeA/d83358199ef46c5379ba257ab0504262 to your computer and use it in GitHub Desktop.
Save ShaikeA/d83358199ef46c5379ba257ab0504262 to your computer and use it in GitHub Desktop.
soup getting keywords
# Narrowing down the space to the article in the page
#(since there are many other irrelevant elements in the page)
article = soup.find(class_="article-wrapper grid row")
# Getting the keywords section
keyword_section = soup.find(class_="keywords-section")
# Same as: soup.select("div.article-wrapper grid row div.keywords-section")
# Getting a list of all keywords which are inserted into a keywords list in line 7.
keywords_raw = keyword_section.find_all(class_="keyword")
keyword_list = [word.get_text() for word in keywords_raw]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment