Python Forum
Handling pound sign (#) within custom URL
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Handling pound sign (#) within custom URL
#1
I'm using requests to compile a custom URL and one parameter includes a pound sign. Can anyone explain how to pass the parameter without the pound sign changing to "%23"?

download URL: www.example.com/type=#results

currently returns: www.example.com/type=%23results

FWIW, this process works if I choose to use the complete URL without passing individual parameters.
Reply
#2
Why do you want to do that? I think it's technically an HTTP violation, if you're seeing the pound in your browser it's because it's changing it behind the scenes.
Reply
#3
(Apr-02-2019, 06:13 PM)micseydel Wrote: Why do you want to do that? I think it's technically an HTTP violation, if you're seeing the pound in your browser it's because it's changing it behind the scenes.

Not sure what you mean by HTTP violation but I'll try and elaborate on what the issue is...I get baseball statistics from this site "https://baseballsavant.mlb.com/statcast_search". There are two download links; 'results' is summarized stats and 'data' is an event log.

The direct download links can be accessed by 1.) inserting 'csv?all=true' within the link and 2.) inserting either 'type=#results' for a summary or 'type=details' for an event log (at the end of the URL).

I'm not familiar enough with URL structures to understand the logic behind all of this but that should at least give you an idea of what I'm dealing with.
Reply
#4
I'm not asking about your use case, I'm asking why you want to use a hash symbol instead of the escaped sequence for it. The sequence should work just fine. Does it not?
Reply
#5
I found this through your identical question on StackOverflow and provided an answer here:

https://stackoverflow.com/a/55482635/9075805

I hope this helps clear things up :)
Reply
#6
(Apr-02-2019, 07:54 PM)micseydel Wrote: I'm not asking about your use case, I'm asking why you want to use a hash symbol instead of the escaped sequence for it. The sequence should work just fine. Does it not?

Oh my bad. I did try replacing '#' with '%23'. The URL then came back with this ending: 'type=details%2523'. On stackoverflow the feedback I got was that everything after '#' gets ignored when using params so now I guess I need to figure out a way to include that portion of the URL outside of params. I'm thinking maybe adding it to the end with a post request but that may just end up giving me the same result.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Does @ at sign used for tother than decorators? ggpython000 1 497 Oct-12-2023, 09:08 AM
Last Post: buran
Star python exception handling handling .... with traceback mg24 3 1,216 Nov-09-2022, 07:29 PM
Last Post: Gribouillis
  Need to sign JWT token with JWK key stucoder 1 1,649 Feb-21-2022, 09:04 AM
Last Post: stucoder
  i making a terminal sign up website thing Kenrichppython 1 1,658 Nov-04-2021, 03:57 AM
Last Post: bowlofred
  Style question on adherence to PEP 8 with whitespace near an "=" sign nilesh 6 3,848 Jan-12-2021, 11:11 PM
Last Post: snippsat
  Syntax Error with = sign and more Kathleen57 3 2,579 May-03-2020, 03:52 AM
Last Post: buran
  problem using custom exception handling in python srm 3 3,000 Jul-03-2019, 09:10 PM
Last Post: ichabod801
  Sign XADES-EPES Python pedro86porras 2 4,177 Nov-02-2018, 04:31 PM
Last Post: pedro86porras
  AttributeError: '_RSAPrivateKey' object has no attribute 'sign' saurya1979 0 6,027 May-02-2018, 03:16 PM
Last Post: saurya1979
  Python code weather Led sign n3vo 21 12,157 May-17-2017, 07:09 PM
Last Post: n3vo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020