Skip to content

Instantly share code, notes, and snippets.

@RKursatV
Last active October 9, 2020 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RKursatV/f08af604e5103e7952ea9bd5bc77c347 to your computer and use it in GitHub Desktop.
Save RKursatV/f08af604e5103e7952ea9bd5bc77c347 to your computer and use it in GitHub Desktop.
Get any url without any trouble as Google
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