Skip to content

Instantly share code, notes, and snippets.

@neelindresh
Created March 3, 2019 15:53
Show Gist options
  • Save neelindresh/ae9d88b42adbb09038e5964863072ac1 to your computer and use it in GitHub Desktop.
Save neelindresh/ae9d88b42adbb09038e5964863072ac1 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import urllib3
import json
http=urllib3.PoolManager()
Abbr_dict={}
#Function to get the Slangs from https://www.noslang.com/dictionary/
def getAbbr(alpha):
global Abbr_dict
r=http.request('GET','https://www.noslang.com/dictionary/'+alpha)
soup=BeautifulSoup(r.data,'html.parser')
for i in soup.findAll('div',{'class':'dictionary-word'}):
abbr=i.find('abbr')['title']
Abbr_dict[i.find('span').text[:-2]]=abbr
linkDict=[]
#Generating a-z
for one in range(97,123):
linkDict.append(chr(one))
#Creating Links for https://www.noslang.com/dictionary/a...https://www.noslang.com/dictionary/b....etc
for i in linkDict:
getAbbr(i)
# finally writing into a json file
with open('ShortendText.json','w') as file:
jsonDict=json.dump(Abbr_dict,file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment