Skip to content

Instantly share code, notes, and snippets.

@Abdujabbar
Created May 6, 2016 06:38
Show Gist options
  • Save Abdujabbar/ac1aa63f53f137da66831126a61a8dfa to your computer and use it in GitHub Desktop.
Save Abdujabbar/ac1aa63f53f137da66831126a61a8dfa to your computer and use it in GitHub Desktop.
stepic solution
import requests
import re
a = input()
b = input()
counter = 0
r = requests.get(a)
found = False
while r.status_code == 200:
links = list(set(re.findall(r"https?://[\w\-.~/?:#\[\]@!$&'()*+,;=]+", str(r.content))))
counter += 1
if counter > 2:
break
if links:
link = links[0]
if counter == 2 and link == b:
found = True
break
r = requests.get(link)
else:
break
if counter == 2 and found:
print("Yes")
else:
print("No")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment