2

I am trying to pull the data using get request through the below URL and I'm getting below error.

I'm not understanding what is the issue with the URL.

Any help would be appreciated

import requests
from requests.auth import HTTPBasicAuth 
import json
import urllib.parse

url = """https://msi.abc.com/admin/ui/feedbackCSV/reports
/5d14de32309baf0001501fb7 ?reports[]=pageviews&reports[]=
searches&from=Oct 1 2020&to=Oct 2 2020"""

encode_url = urllib.parse.quote(url,encoding='utf-8')

response = requests.get(encode_url,auth = HTTPBasicAuth('[email protected]', 'Summer2020')) 
print(response.content)

Error

raise MissingSchema(error) requests.exceptions.MissingSchema: Invalid URL 'https%3A%2F%2Fmsi.abc.com%2Fadmin%2Fui%2FfeedbackCSV%2Freports%0D%0A%2F5d14de32309baf0001501fb7%20%3Freports%5B%5D%3Dpageviews%26reports%5B%5D%3D%0D%0Asearches%26from%3DOct%201%202020%26to%3DOct%202%202020': No schema supplied. Perhaps you meant http:https%3A%2F%2Fmsi.abc.com%2Fadmin%2Fui%2FfeedbackCSV%2Freports%0D%0A%2F5d14de32309baf0001501fb7%20%3Freports%5B%5D%3Dpageviews%26reports%5B%5D%3D%0D%0Asearches%26from%3DOct%201%202020%26to%3DOct%202%202020?

4
  • How is the Output URL should look like? Can you put an example? Commented Nov 19, 2020 at 4:00
  • @HarshanaSerasinghe I have this url msi.abc.com/admin/ui/feedbackCSV/reports /5d14de32309baf0001501fb7 ?reports[]=pageviews&reports[]= searches&from=Oct 1 2020&to=Oct 2 2020 i'm encoding this url to parse special char in uri using urllib.parse.quote(url,encoding='utf-8') Commented Nov 19, 2020 at 4:24
  • Okay. Is the host name 'msi.abc.com' a correct one or you just add it as an example? Commented Nov 19, 2020 at 4:35
  • I added it as an example. Commented Nov 19, 2020 at 4:37

1 Answer 1

2

This might be due to that you pass the whole URL to the urllib.parse.quote function. Try passing the params only to the urllib.parse.quote or use requests params like in the below example:

import requests
from requests.auth import HTTPBasicAuth 
import json
import urllib.parse

url = "https://msi.abc.com/admin/ui/feedbackCSV/reports/5d14de32309baf0001501fb7"
payload = {'reports[]':'pageviews', 'reports[]':'searches','from':'Oct 1 2020', 'to':'Oct 2 2020' }

authParams = HTTPBasicAuth('[email protected]', 'Summer2020')

response = requests.get(url,params=payload, auth =authParams ) 
print(response.content)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.