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
0
votes
1 answer

Regex split to get top level domain and sub directory

I want to split the URL till sub directory if available else TLD, How to acheive this using Regex? www.xyx.com/features.html => www.xyx.com/ to be selected and www.xyx.com/abc/features.html => www.xyx.com/abc/ to be selected It includes https,…
Bala
  • 1
0
votes
1 answer

joining urls with urljoin in python

I am trying to do some web scraping but I have some problems in joining relative and root urls for example the root url is: http://www.jmlr.org/proceedings/papers/v2 and the relative url is: ../v2/meila07a/meila07a.pdf As I use urljoin in urlparse:…
So Amin
  • 1
  • 1
0
votes
2 answers

Unable to parse Url with python urlparse

I am trying to write a small script that will take url as input and will parse it. Following is my script #! /usr/bin/env python import sys from urlparse import urlsplit url = sys.argv[1] parseUrl = urlsplit(url) print 'scheme :',…
Sajjad
  • 853
  • 2
  • 15
  • 32
0
votes
1 answer

Using urlparse to remove a certain string?

I have this URL: www.domain.com/a/b/c/d,authorised=false.html and I want to convert it into www.domain.com/a/b/c/d.html Please note I am using python 2.7. from urlparse import urlparse url =…
Sushi
  • 631
  • 1
  • 8
  • 19
0
votes
1 answer

Reusing Spring RequestMapping parsing functionality

I have some properties like /my/{custom}/url I would need to replace {custom} with some value at runtime I know that Spring is using "@RequestMapping" with a similar syntax for @PathAttribute matching. I'm wondering if there is some Class I can…
spike07
  • 809
  • 2
  • 12
  • 21
0
votes
1 answer

python urljoin directory not includ

I want to fix some situations about urlparse.urljoin. Using this lib like urljoin('http://xxxx.yyy/directory/','file.file') gives me http://xxxx.yyy/directory/file.file but if i don't give slash at last in url…
Peter Yang
  • 43
  • 4
0
votes
2 answers

Web Crawler error: "AttributeError: Spider instance has no attribute 'find'"

I'm having an issue with my web crawler and the urlparse plugin for python. My code below basically crawls a specific domain such as bloomberg and downloads all the html to my desktop. It's still in quite early stage so I'm sure you will notice…
Isaac
  • 1,371
  • 3
  • 14
  • 36
0
votes
1 answer

Aptana Python stdlib issue with virtualenv

      I recently started working on a project using just vim as my text editor with a virtualenv setup. I installed a few API's on this virtualenv from GitHub. Eventually, the project got a little bigger than vim could handle so I had to move the…
Sandwich Heat
  • 559
  • 1
  • 8
  • 20
0
votes
1 answer

Python Adding Headers to urlparse

There doesn't appear to be a way to add headers to the urlparse command. This essentially causes Python to use its default user agent, which is blocked by several web pages. What I am trying to do is essentially do the equivalent of this: req =…
NAME__
  • 625
  • 1
  • 7
  • 17
0
votes
1 answer

Urlecoding a string back from a dictionary

I am trying to remove certain items from a query string, the best way doing this would be to parse the query string, iterate over and remove the particular key I dont want and join it all back together. Following the python guide, it seems the…
Wizzard
  • 12,582
  • 22
  • 68
  • 101
0
votes
1 answer

Urlparse and '\n'

I have: from urlparse import urlparse s = "http://google.com" + "\n" # this line is read from file, when I loop over file's lines urlparse(s) ParseResult(scheme='http', netloc='google.com\n', path='', params='', query='', fragment='') Is this…
Simon
  • 2,329
  • 4
  • 30
  • 49
0
votes
1 answer

Adding parameter values to a url in flask python

I have the code for the following url:http://localhost/summary/myfile.csv I want the url to look like this:http://localhost/summary?file=myfile.csv The code is to be written in flask. My code for the first url is as…
Code Ninja
  • 6,963
  • 5
  • 16
  • 12
0
votes
3 answers

How to insert an additional path into URL using PHP?

Let say I've this URL: http://example.com/image-title/987654/ I want to insert "download" to the part between "image-title" and "987654" so it would look like: http://example.com/image-title/download/987654/ help would be greatly appreciated! thank…
Rifki
  • 17
  • 1
  • 5
0
votes
2 answers

splitting a path with python

I am trying to get cut everything off after the last decimal and add "html" to the end html http://www.youversion.com/bible/gen.1.ceb current code returns "gen.1.ceb" name =…
Blainer
  • 2,552
  • 10
  • 32
  • 39
-1
votes
1 answer