Skip to content

Instantly share code, notes, and snippets.

@Kakarot-2000
Last active May 8, 2021 02:36
Show Gist options
  • Save Kakarot-2000/d3d95a9daf3348c7159ef74d9a3a5cad to your computer and use it in GitHub Desktop.
Save Kakarot-2000/d3d95a9daf3348c7159ef74d9a3a5cad to your computer and use it in GitHub Desktop.
def getLink(number):
link='https://www.google.com/search?q='+'geeksforgeeks puzzle '+number
response=requests.get(link)
ls=[]
links=[]
try:
soup=bs4.BeautifulSoup(response.text,features="html.parser")
for tag in soup.find_all('a'):
ls.append(tag.get('href'))
for link in ls:
if(link.startswith('/url?q=https://www.geeksforgeeks.org/puzzle-'+number)==True):
end=0
index=37
for c in link[37:]:
if c=='/':
end=index
break
index+=1
links.append(link[7:end])
break
return links
except:
print('Error')
return ['No Links Found!!']
raise()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment