Questions tagged [url-parsing]

URL parsing is the process of taking a URL and producing a representation of its constituent parts: scheme, host, port, path, query, and fragment. The URL Standard defines an algorithm for URL parsing.

See https://url.spec.whatwg.org/#url-parsing

166 questions
4
votes
1 answer

Parsing query string inside fragment with Elm

For reasons I need to parse something which looks is formatted as a query string (i.e. key=value&another_key=another_value), but which is in the fragment of a URL, e.g: http://example.com/callback#id_token=my_long_jwt&state=some_state If the # was a…
davetapley
  • 17,000
  • 12
  • 60
  • 86
4
votes
1 answer

urllib.parse Python2.7 equivalent

What is the Python2.7 equivalent to from urllib.parse import urlparse, parse_qs parsed_url = urlparse(url) params = parse_qs(parsed_url.query) I get >>> from urllib.parse import urlparse Traceback (most recent call last): File "", line 1,…
Cranjis
  • 1,590
  • 8
  • 31
  • 64
4
votes
3 answers

Get page URL parameters from a service worker

How do I get page URL with parameters from a service worker? I have tried self.registration.scope but that doesn't include the parameters.
Ethan
  • 3,410
  • 1
  • 28
  • 49
4
votes
5 answers

How to remove the protocol and domain from a url string?

I am running the following code in PHP. My intention is to get "contact.html" in the response, but what I actually get in the output is ntact.html $str = 'http://localhost/contact.html'; echo $str . "
"; echo ltrim($str,'http://localhost'); Any…
Varun Verma
  • 704
  • 2
  • 10
  • 20
4
votes
2 answers

Split URL into Host, Port and Resource - C++

I need to split the URL into host, port and resource. I searched a lot of references but couldn't find anything that could help me. This is how I want: eg: url is - 1.2.3.4:5678/path1/path2.html Necessary output is: Host - 1.2.3.4, Port - 5678,…
Electronic Brat
  • 133
  • 1
  • 2
  • 11
4
votes
2 answers

Parsing URLs in Postgres

I'm having trouble parsing urls in Postgres. I have a database full of customers and urls associated with them. I need an array of the unique domains associated with each customer. I'd love to be able to do the parsing in my query instead of dumping…
davidshere
  • 315
  • 3
  • 10
4
votes
3 answers

How to parse URLs in C using sscanf()?

This is my C code that reads a list of URLs from a file, and tries to separate the various parts of the URL. This is just rough parsing, I'm not bothered about special cases. I guess there is some fault with the sscanf() statement; when I run this,…
trinity
  • 10,394
  • 15
  • 49
  • 67
4
votes
0 answers

Getting URL Parameters Based on a Template/Pattern

In order to perform AJAX calls, I extract URL values (embedded IDs and query string parameters) and store them in hidden inputs. Outside of this little bit of server-side work, I have a static HTML page. I am looking for a library that can easily…
Travis Parks
  • 8,435
  • 12
  • 52
  • 85
4
votes
1 answer

Unable to handle square brackets (=[]) when parsing of URL to server

I am calling the following URL from my iPhone app NSString *resourcePath = [NSString stringWithFormat:@"/sm/search?limit=100&term=%@&types[]=users&types[]=questions", searchTerm]; However, when the server call is made, I found that the actual URL…
Zhen
  • 12,361
  • 38
  • 122
  • 199
3
votes
1 answer

How to get a subdirectory in the path of a URL?

I am looking for a way to split a URL, such as http://aaa/bbb/ccc/ddd/eee. How do I get "ccc"? Of course it is possible to split it, but it is not interesting.
Wild Goat
  • 3,509
  • 12
  • 46
  • 87
3
votes
8 answers

Parse mailto urls in Python

I'm trying to parse mailto URLs into a nice object or dictionary which includes subject, body, etc. I can't seem to find a library or class that achieves this- Do you know of any? mailto:me@mail.com?subject=mysubject&body=mybody
Yarin
  • 173,523
  • 149
  • 402
  • 512
3
votes
2 answers

How to extract the filename from a URL in Elixir?

Here's my problem I want to get the file name from the URL ex. https://randomWebsite.com/folder/filename.jpeg I got the expected result on javascript using this string.substring(string.lastIndexOf('/')+1). In Elixir I use this function…
Gelo Chang
  • 127
  • 8
3
votes
2 answers

Determine if Host is Domain Name or IP in Python

Is there a function in Python that determines if a hostname is a domain name or an IP(v4) address? Note, the domain name may look like: alex.foo.bar.com or even (I think this is valid): 1.2.3.com.
Alex Rothberg
  • 10,243
  • 13
  • 60
  • 120
3
votes
2 answers

urljoin when an absolute path does not have a leading slash

Some websites like http://www.gilacountyaz.gov/government/assessor/index.php have a bunch of internal links that should be absolute paths, but do not have the leading slash. When parsing them with urlparse.urljoin the result is the following: >>>…
Mikk
  • 804
  • 8
  • 23
3
votes
4 answers

Parse request URL in JSTL

I want to display a specific message based on the URL request on a JSP. the request URL can be: /app/cars/{id} OR /app/people/{id} On my messages.properties I've got: events.action.cars=My car {0} event events.action.people=My person {1}…
JorgeO
  • 2,210
  • 5
  • 20
  • 22
1 2
3
11 12