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
2
votes
4 answers

how do i replace a query with a new value in urlparse?

so I have a data as follows: item = '//s780.scene7.com/is/image/forever/301596014_001?hei=98&wid=98' using urlparse module. how can i replace the above data with a new size to make it look like this: item =…
slopeofhope
  • 686
  • 2
  • 6
  • 21
2
votes
1 answer

How to parse URLs using urlparse and split() in python?

Could someone explain to me the purpose of this line host = parsed.netloc.split('@')[-1].split(':')[0]in the following code? I understand that we are trying to get the host name from netlock but I don't understand why we are splitting with the @…
masterpiece
  • 573
  • 3
  • 10
  • 19
2
votes
2 answers

Javascript equivalent of Python's urlparse.parse_qs()?

I am using python to generate a query string which will then be parsed by javascript. Consider a fairly "complex" piece of data: import urllib params = { 'record': 'customer', 'filters': [ ('id', '>', 5), …
poundifdef
  • 18,726
  • 23
  • 95
  • 134
2
votes
2 answers

Python CSV row value based flow control

I am working with a CSV that has the following structure: "2012-09-01 20:03:15","http://example.com" The data is a cleaned up dump of my browsing history. I am interested in counting the first five unique domains per a given day. Here is what I…
dongle
  • 599
  • 1
  • 4
  • 17
1
vote
0 answers

How to check if 2 urls in same domain?

I was trying to check if 2 urls have same domain using prase.urlparse like this: if parse.urlparse(url1).hostname == parse.urlparse(url2).hostname: print('Same Domain') else: print('Different Domain') While this works for:…
1
vote
1 answer

Python Misses Parsing arguments?

I wrote the following code to extract Get parameters from url like this: from urllib.parse import urlparse from urllib.parse import parse_qs url = 'https://www.example.com/some_path?some_key=some_value&tt=new_value' parsed_url = urlparse(url) for…
zoro
  • 15
  • 5
1
vote
1 answer

python - Retrieve and save links from webpage but only one per domain

I'm having a bit of trouble trying to save the links from a website into a list without repeating urls with same domain Example: www.python.org/download and www.python.org/about should only save the first one (www.python.org/download) and not…
1
vote
1 answer

Create and urlparse an URL that has to include a variable being a list of strings

I am using the following code to parse an URL: url3 = "https://flyingcar.org/dfr/?d=34u&f=56&dossier=ZT18174&document=US1234567&docs='US1','US2','US3'#{'para1':'UK','para2':'Ireland'}" parsed = urlparse(url3) print('url:\n',url3) captured_values =…
JFerro
  • 3,203
  • 7
  • 35
  • 88
1
vote
1 answer

InvalidArgumentException: Message: invalid argument: 'url' must be a string invoking url using get()

First, I got the total url of all pages. However, When I want to get into each page (page by page),it failed. How could I get into each page? !pip install selenium from selenium import webdriver from selenium.webdriver.common.by import By from…
1
vote
1 answer

URL API parser alternative for Google Scripts

The javascript used by Google Scripts does not include the URI API library for parsing URLs. It also does not support complex (perl-like backwards looking) regular expressions. As far as I know you can't import public libraries. This makes it hard,…
ThePirate
  • 33
  • 5
1
vote
2 answers

Grab the values from url that is in between specific characters BigQuery

I need to parse urls in order to grab a value that comes after .com/ AND before the next / character. My data looks like…
Chique_Code
  • 1,422
  • 3
  • 23
  • 49
1
vote
2 answers

Extract urls information from pandas column

I need to keep some parts of a link: Link www.xxx.co.uk/path1 www.asx_win.com/path2 www.asdfe.aer.com ... Desired output: Link2 xxx.co.uk asx_win.com asdfe.aer.com ... I used urlparse and tldextract but I get…
LdM
  • 674
  • 7
  • 23
1
vote
1 answer

Change url in python

how can I change the activeOffset in this url? I am using Python and a while loop https://www.dieversicherer.de/versicherer/auto---reise/typklassenabfrage#activeOffset=10&orderBy=kh&orderDirection=ASC It first should be 10, then 20, then 30 ... I…
Lara
  • 23
  • 3
1
vote
1 answer

URL parsing: Get N number of folders followed by filename starting from a certain folder

I have a URL which could have any number of folders, and it ends with a filename.extension. example: https://cdn.example.com/user/image/upload/v87879798/images/profile/oaz4wkjkjsbzxa3xlkmu.jpg I am trying to get everything after the /v87879798…
coredumped0x
  • 768
  • 1
  • 12
  • 28
1
vote
2 answers

How can I parse the query in url in react js using url-parse package?

I want to parse the query in the url in react js like this : const location = useHistory().location; const parsed = parse(location, true); console.log(parsed); But the console gives me this : host: "localhost:3000" hostname: "localhost" href:…
Mehdi Faraji
  • 2,574
  • 8
  • 28
  • 76