Can parse JSON web pages
This commit is contained in:
parent
02bebb663c
commit
88d976fb60
1 changed files with 9 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import http.client
|
import http.client
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
from urllib.parse import quote
|
from urllib.parse import quote
|
||||||
|
@ -130,6 +131,14 @@ def getXML(url, timeout=15):
|
||||||
else:
|
else:
|
||||||
return xmlparser.parse_string(cnt)
|
return xmlparser.parse_string(cnt)
|
||||||
|
|
||||||
|
def getJSON(url, timeout=15):
|
||||||
|
"""Get content page and return JSON content"""
|
||||||
|
cnt = getURLContent(url, timeout)
|
||||||
|
if cnt is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return json.loads(cnt.decode())
|
||||||
|
|
||||||
def traceURL(url, timeout=5, stack=None):
|
def traceURL(url, timeout=5, stack=None):
|
||||||
"""Follow redirections and return the redirections stack"""
|
"""Follow redirections and return the redirections stack"""
|
||||||
if stack is None:
|
if stack is None:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue