Questions tagged [urlparse]

urlparse is used for parsing a URL into components like (addressing scheme, network location, path etc.)

urlparse is module in Python2.7 and renamed to urllib.parse in Python 3

Links:

urlparse

urllib.parse

196 questions
6
votes
3 answers

Hey can you help me out . my 'url.parse' is deprecated

line 5 @deprecated — since v11.0.0 - Use the WHATWG URL API. The signature '(urlStr: string): UrlWithStringQuery' of 'url.parse' is deprecated url .The declaration was marked as deprecated here.
Ramzi
  • 71
  • 1
  • 1
  • 5
6
votes
4 answers

Update/add username in url in python

If I have a URL (ex: "ssh://hello@xyz.com:553/random_uri", "https://test.blah.blah:993/random_uri2"), I want to set/update the username in the url. I know there is urllib.parse.urlparse (https://docs.python.org/3/library/urllib.parse.html) that…
ozn
  • 1,990
  • 3
  • 26
  • 37
6
votes
2 answers

Parse a git URL like 'ssh://git@gitlab.org.net:3333/org/repo.git'?

How could I easily extract hostname from a git URL like ssh://git@gitlab.org.net:3333/org/repo.git u = urlparse(s) gives me ParseResult(scheme='ssh', netloc='git@gitlab.org.net:3333', path='/org/repo.git', params='', query='', fragment='') which…
d33tah
  • 10,999
  • 13
  • 68
  • 158
6
votes
2 answers

python, "urlparse.urlparse(url).hostname" return None value

After loging in on a website I want to collect its links. This I do with this function (using mechanize and urlparse libraries): br = mechanize.Browser() . . #logging in on website . for link in br.links(): url =…
user3053161
  • 291
  • 3
  • 8
5
votes
4 answers

Python's `urlparse`: Adding GET keywords to a URL

I'm doing this: urlparse.urljoin('http://example.com/mypage', '?name=joe') And I get this: 'http://example.com/?name=joe' While I want to get this: 'http://example.com/mypage?name=joe' What am I doing wrong?
Ram Rachum
  • 84,019
  • 84
  • 236
  • 374
5
votes
2 answers

pythonic way to parse/split URLs in a pandas dataframe

I have a df that has thousands of links like the ones below, for different users, in a column labeled…
Luis Miguel
  • 5,057
  • 8
  • 42
  • 75
5
votes
2 answers

Python urlparse.unparse_qsl?

In Python's urlparse, you can use urlparse to parse the URL, and then parse_qsl to parse the query. I want to remove a query (name, value) pair, and then reconstruct the URL. There is a urlunparse method, but no unparse_qsl method. What is the…
Joseph Turian
  • 15,430
  • 14
  • 47
  • 62
4
votes
1 answer

Getting the Parameter name of a Value in a URL request

I have a Python App Engine web app class that I am accessing with the following POST url: http://localhost:8087/moderate?5649364211118945661=on How can I get the Parameter name - not the value of the 5649364211118945661parameter, but a list of all…
Isaac Lewis
  • 1,189
  • 2
  • 14
  • 26
4
votes
2 answers

Angular 9 - parse each parameter for a given url

Suppose we have these kinds of urls: [1] /home/users/:id [2] /home/users/:id/posts/:id [3] /home/users/:id/posts/:id/comments/:id I want to make a method parseUrl(url: string): any[] {} which takes a url and returns an array containing each and…
dc_Bita98
  • 851
  • 2
  • 17
  • 35
4
votes
1 answer

Why does my webcrawler not follow into the next link containing keywords

I have written a simple webcrawler that will eventually follow only news link to scrape the article text into a database. I am having problems actually following the link from the source url. This is the code so far: import urlparse import…
Gaddi
  • 167
  • 1
  • 3
  • 16
4
votes
2 answers

Python urlparse, correct or incorrect?

Python's urlparse function parses an url into six components (scheme, netloc, path and others stuff) Now I've found that parsing "example.com/path/file.ext" return no netloc but a path "example.com/path/file.ext". Should't it be netloc =…
Ben
  • 16,275
  • 9
  • 45
  • 63
3
votes
2 answers

How To Parse URL in Deno

How do you parse a URL in deno like node.js url.parse()?
Timothy C. Quinn
  • 3,739
  • 1
  • 35
  • 47
3
votes
2 answers

Change hostname of URL with urllib

I want to change the hostname of a URL. >>> import urllib >>> url = "https://foo.bar.com:9300/hello" >>> parsed = urllib.parse.urlparse(url) >>> parsed ParseResult(scheme='https', netloc='foo.bar.com:9300', path='/hello', params='', query='',…
Vermillion
  • 1,238
  • 1
  • 14
  • 29
3
votes
2 answers

Equivalent urllib.parse.unquote() in python 2.7

I import urlparse instead of urllib.parse in python 2.7 but getting AttributeError: 'function' object has no attribute 'unquote' File "./URLDefenseDecode2.py", line 40, in decodev2 htmlencodedurl = urlparse.unquote(urlencodedurl) What is the…
irom
  • 3,316
  • 14
  • 54
  • 86
3
votes
2 answers

How to parse a utf-8 encoded query parameter with Python 2.6

I have some lovely (Scandinavian?) user on my website complaining that I cannot parse his username in URLs, and hence I am showing him no results on his page on my website. I am pretty sure that the browser encodes the requests as…
Rob Neuhaus
  • 9,190
  • 3
  • 28
  • 37
1 2
3
13 14