Last active
May 8, 2021 02:36
-
-
Save Kakarot-2000/d3d95a9daf3348c7159ef74d9a3a5cad to your computer and use it in GitHub Desktop.
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
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