Last active
October 9, 2020 20:54
-
-
Save RKursatV/f08af604e5103e7952ea9bd5bc77c347 to your computer and use it in GitHub Desktop.
Get any url without any trouble as Google
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
import requests | |
import json | |
import re | |
def getUrlAsGoogle(coolUrl): | |
while True: | |
try: | |
coolUrl = "https://docs.google.com/viewer?url=" + coolUrl | |
req = requests.get(coolUrl, | |
headers={'User-agent': 'Mozilla/5.0', 'Accept-Encoding': 'identity'}, | |
timeout=2) | |
assert req.content != b'' | |
_googleUrl = re.findall(r'"text\?id\\\\u003d(((?!(")).)*)"', str(req.content))[0][0] | |
req = requests.get("https://docs.google.com/viewerng/text?id=" + _googleUrl, | |
headers={'User-agent': 'Mozilla/5.0', 'Accept-Encoding': 'identity'}, | |
timeout=2) | |
googleData = json.loads(req.content[5:])["data"] | |
return googleData | |
except: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment