shizde
shizde

Reputation: 40

Know if external url was accessed in python

I want to build a webscraping application in python to know if a url that is outside my domain is accessed. Can I do it with flask endpoint?

Something like:

app.route('https://www.example.com/?userid=1',method=['GET'])
def count_acces(id_user):
   <code>
   return id_user

Upvotes: 0

Views: 151

Answers (1)

MertG
MertG

Reputation: 763

Use requests module. Check out more here

import requests

try:
    url = "https://some_wrong_url.wrong"
    requests.request("GET", url)
except requests.RequestException as e:
    print(e)

Upvotes: 1

Related Questions