Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last month.
Improve this question
So I'm trying to randomly generate an insult from this API. I'm getting a response 200 from the API but I can't seem to extract data
I'm using this code:
def get_insult():
res = requests.get('https://insult.mattbas.org/api/insult.txt')
print(res)
data_json = json.loads(res.json())
print(data_json)
get_insult()
This should work. You don't need to use json.loads() as the response is not json.
def get_insult():
res = requests.get('https://insult.mattbas.org/api/insult.txt')
data_json = res.text
print(data_json)
get_insult()
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 days ago.
Improve this question
I have the following problem. I have a JSON dataset where I would like to retrieve the data as follows: "id: XXXXXXX" wehere the x = numbers. The numbers are followed by "," and I just want to get the data up to that point. All datas what I mining want to save another txt file.
import json
f = open('data.json')
data = json.load(f)
I hope everthing is clear. :)
:)
I tried a few different possibility but I can not get solve my problem.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
When i extract a url, it displays as below
https://tv.line.me/v/14985624_%E0%B8%A0%E0%B8%B9%E0%B8%95%E0%B8%A3%E0%B8%B1%E0%B8%95%E0%B8%95%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A5-ep3-6-6-%E0%B8%8A%E0%B9%88%E0%B8%AD%E0%B8%878
how do i convert this to more readable format like below in python. The link below is the same as above.
Link to the image of how the url appears on browser address bar
You can use urllib module to decode this url
from urllib.parse import unquote
url = unquote('https://tv.line.me/v/14985624_%E0%B8%A0%E0%B8%B9%E0%B8%95%E0%B8%A3%E0%B8%B1%E0%B8%95%E0%B8%95%E0%B8%B4%E0%B8%81%E0%B8%B2%E0%B8%A5-ep3-6-6-%E0%B8%8A%E0%B9%88%E0%B8%AD%E0%B8%878')
print(url)
This will give you the result as follows.
https://tv.line.me/v/14985624_ภูตรัตติกาล-ep3-6-6-ช่อง8
Thank you
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
This is the site I can open in Chrome and see text:
ftp://ftp.cmegroup.com/pub/settle/stlags
Any idea how to read this into a string in python?
Don`t know if this helps but this will get you the html of a website:
import urllib.request
url = "ftp://ftp.cmegroup.com/pub/settle/stlags"
html = urllib.request.urlopen(url)
htmlB=html.read()
htmlS = htmlB.decode()
print(htmlS)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
This is how the data stored in Firebase
This is the output
This is the code
from firebase import firebase
url = "https://xxxx.firebaseio.com/"
fb = firebase.FirebaseApplication(url,None)
Humidity = fb.get("/Humidity",None)
for key, value in Humidity.items():
print("Humidity :{}".format(value["hum"]))
Try this...
snapshot = ref.order_by_child('/Humidity').get()
for more look at this link
https://firebase.google.com/docs/database/admin/retrieve-data
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to store response of the request in scrapy .i have the following code for the time being.
yield Request(requestURL,
callback=self.afterResponse)
Now what i want not to call the function afterResponse upon arrival of response but to store it here somehow so that i can extract the data of response at the same place.
Create some variable (it can be even list if you need to keep more data) in that spider and keep that data in it.
Or create/open some file and write it as pickle or something.