Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8092765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:21:25+00:00 2026-06-05T20:21:25+00:00

I got some pretty messy urls that i got via scraping here, problem is

  • 0

I got some pretty messy urls that i got via scraping here, problem is that they contain spaces or other special characters in the path and query string, here is some example

http://www.example.com/some path/to the/file.html
http://www.example.com/some path/?file=path to/file name.png&name=name.me

so, is there an easy and robust way to escape the urls so that i can pass them to urlopen?
i tried urlib.quote, but it seems to escape the ‘?’, ‘&’, and ‘=’ in the query string as well, and it seems to escape the protocol as well,
currently, what i am trying to do is use regex to separate the protocol, path name, and query string and escape them separately, but there are cases where they arent separated properly
any advice is appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:21:27+00:00Added an answer on June 5, 2026 at 8:21 pm

    urllib.quote will quote everything except / by default. You can pass it a list of characters to leave alone as the second argument:

    urllib.quote('http://www.example.com/some path/?file=path to/file name.png&name=name.me',
                 '/:?&=')
    'http://www.example.com/some%20path/?file=path%20to/file%20name.png&name=name.me'
    

    But this is pretty tricky stuff to be messing with semimanually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a DataGridView with a ComboBox in it that might contain some pretty
I've got some Excel spreadsheets that are hitting the database pretty hard (100+ queries
I got some radio controls that in JQuery Mobile 1.0.1 (stable) were working pretty
I've got some code hosted at a svn server; I'm pretty sure they do
So I've got a pretty basic class that has a few methods and some
I've got an auxiliary function that does some operations that are pretty costly. I'm
We've got some pretty complex code that's utilising the drag and drop functionality provided
Pretty simple question. I've got some Polygons and GroundOverlays defined in KML. Is there
i've got a pretty simple .NET console application. I wish to pass in some
Got some code that is not mine and its producing this warning atm: iehtmlwin.cpp(264)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.