django - How to retrieve data from a url in python and then send it to the file from which i can work on that data below is how i retrieve data -
How to obtain data from a URL in Python and then send the file so that I can work on that data. Import the data below
Django.http Import HttpResponse import urllib def indexx (requested): url = "http: // #########/query? condition =% s & key = e25c7 & amp; op = json" Condition = 'aaaaa' x = urllib.urlopen (url% condition) y = htppspax (xrade) returns (y)
You really do not need all of this.
With linked documents, you can easily do this:
& gt; & Gt; & Gt; R = requests.get ('https://api.github.com/user', auth = ('user', 'pass')) & gt; & Gt; & Gt; R.status_code 200 & gt; & Gt; & Gt; R.headers ['Content-Type'] 'Application / Jason; Charset = utf8 '& gt; & Gt; & Gt; R.encoding 'utf-8' & gt; & Gt; & Gt; R.text u '{"Type": "User" ...' & gt; & Gt; & Gt; R.json {u'private_gists ': 419, u'total_private_repos': 77, ...} If you want, you can also write all the contents in the file, but you can Indeed it should be written in memory which can be saved on disk using SQLite or Redis.
Comments
Post a Comment