from urllib.request import Request, urlopen
      
      ENDPOINT_URL = "http://www.iabdullahmughal.com"
      request = Request(ENDPOINT_URL)
      USER_AGENT = "python code"
      request.add_header('Connection', 'keep-alive')
      request.add_header('Cache-Control', 'max-age=0')
      request.add_header('DNT', '1')
      request.add_header('Upgrade-Insecure-Requests', '1')
      request.add_header('Accept-Language', 'en-US,en;q=0.9')
      request.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,'
                                   'image/avif,image/webp,'
                                   'image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9')
      request.add_header('User-Agent', f'{USER_AGENT}')
      with urlopen(request) as GATEWAY:
          CONTENT = GATEWAY.read()
          print(CONTENT)
      
      Python language logo

      Get request with urllib

      python-requets
      download-html
      get-request
      Handle Internet With Python

      Read data from webpage using **python3 buildin request ** function

      Following python code can send get request to a web page and download html document. Later this downloaded documented is printed on console.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.