Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored urllib to be compatible with Python 3 #14

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions harsanitizer/harsan_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import datetime
import json
import urllib2
from urllib.request import urlopen
from flask import Flask, url_for, request, Response, render_template_string
import decorators
from harsanitizer import Har, HarSanitizer
Expand Down Expand Up @@ -63,7 +63,7 @@ def json_serial(obj):
@app.route("/")
def index():
if STATIC_FOLDER[:4] == "http":
index_html_str = urllib2.urlopen(INDEX_PATH).read()
index_html_str = urlopen(INDEX_PATH).read()
else:
with open(INDEX_PATH, "r") as index_file:
index_html_str = index_file.read()
Expand All @@ -76,7 +76,7 @@ def get_wordlist():

try:
if WORDLIST_PATH[:4] == "http":
wordlist_json = json.loads(urllib2.urlopen(WORDLIST_PATH).read())
wordlist_json = json.loads(urlopen(WORDLIST_PATH).read())
wordlist = hs.load_wordlist(wordlist=wordlist_json)
else:
wordlist = hs.load_wordlist(wordlist_path=WORDLIST_PATH)
Expand All @@ -96,7 +96,7 @@ def get_mimetype_scrublist():

try:
if MIMETYPES_PATH[:4] == "http":
mimetype_scrub_list = json.loads(urllib2.urlopen(MIMETYPES_PATH).read())
mimetype_scrub_list = json.loads(urlopen(MIMETYPES_PATH).read())
else:
with open(MIMETYPES_PATH, "r") as mimetypes_file:
mimetype_scrub_list = json.load(mimetypes_file)
Expand Down
4 changes: 2 additions & 2 deletions harsanitizer/harsanitizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import os
import json
import re
import urllib2
from urllib.request import urlopen


# Config local/remote file locations
Expand Down Expand Up @@ -604,7 +604,7 @@ def scrub(
raise TypeError("'har' must be a Har object")

if WORDLIST_PATH[:4] == "http":
wordlist_json = json.loads(urllib2.urlopen(WORDLIST_PATH).read())
wordlist_json = json.loads(urlopen(WORDLIST_PATH).read())
scrub_wordlist = self.load_wordlist(wordlist=wordlist_json)
else:
scrub_wordlist = self.load_wordlist(wordlist_path=WORDLIST_PATH)
Expand Down