
import urllib.request


class WebAdapter:
    def get(self, urllike):
        url = self.mk_url(urllike)
        try:
            res = urllib.request.urlopen(url)
            return res.read()
        except Exception as e:
            raise e

    def open(self, urllike):
        url = self.mk_url(urllike)
        try:
            return urllib.request.urlopen(url)
        except Exception as e:
            raise e

    def mk_url(self, urllike):
        return str(urllike)


import requests


class WebAdapter:
    def __init__(self):
        self.cookies = {}

    def get(self, urllike):
        res = requests.get(str(urllike), cookies=self.cookies)
        self.cookies = res.cookies
        return res.text

Use requests instead of urllib.request
Use requests instead of urllib.request

  
- import urllib.request
+ import requests
  
  
  class WebAdapter:
+     def __init__(self):
+         self.cookies = {}
+ 
      def get(self, urllike):
+         res = requests.get(str(urllike), cookies=self.cookies)
+         self.cookies = res.cookies
-         url = self.mk_url(urllike)
-         try:
-             res = urllib.request.urlopen(url)
-             return res.read()
+         return res.text
-         except Exception as e:
-             raise e
  
-     def open(self, urllike):
-         url = self.mk_url(urllike)
-         try:
-             return urllib.request.urlopen(url)
-         except Exception as e:
-             raise e
- 
-     def mk_url(self, urllike):
-         return str(urllike)
- 
Use requests instead of urllib.request
## Code Before:

import urllib.request


class WebAdapter:
    def get(self, urllike):
        url = self.mk_url(urllike)
        try:
            res = urllib.request.urlopen(url)
            return res.read()
        except Exception as e:
            raise e

    def open(self, urllike):
        url = self.mk_url(urllike)
        try:
            return urllib.request.urlopen(url)
        except Exception as e:
            raise e

    def mk_url(self, urllike):
        return str(urllike)

## Instruction:
Use requests instead of urllib.request
## Code After:

import requests


class WebAdapter:
    def __init__(self):
        self.cookies = {}

    def get(self, urllike):
        res = requests.get(str(urllike), cookies=self.cookies)
        self.cookies = res.cookies
        return res.text
