Reputation: 251
I am trying to use requests library to get contents of url.
url:https://zee5transcoding-news-staging.s3.ap-south-1.amazonaws.com/RSS_Feed/rss_xml/rss_xml_2.xml
It opens in browser as following:
but when I use the python code to fetch this content using requests library the output is as follow:
The python code is as follows:
import json
import requests
response = (requests.get("https://zee5transcoding-news-staging.s3.ap-south-1.amazonaws.com/RSS_Feed/rss_xml/rss_xml_2.xml" ).text)
print((response))
All the bengali language characters are somehow encoded i guess. Please help me to get the same content as I see in browser via python requets library.
Upvotes: 1
Views: 534
Reputation: 1281
use .content instead of .text
import json
import requests
response = requests.get("https://zee5transcoding-news-staging.s3.ap-south-1.amazonaws.com/RSS_Feed/rss_xml/rss_xml_2.xml" ).content
with open("try.txt","a",encoding="utf8") as w:
w.writelines((response).decode("utf8"))
Upvotes: 0