Question: I am iterating over multiple URLs in a csv file; the URLs have the next structure:

```
http://www.parool.nl/parool/nl/4024/AMSTERDAM-CENTRUM/article/detail/3751723/2014/09/21
http://www.parool.nl/parool/nl/5/POLITIEK/article/detail/3751624/2014/09/20/VVD-wil-  boete-van-250-euro-voor-het-naroepen-van-vrouwen.dhtml

```

etc., 

I need to get the article category (after the 4th slash, "AMSTERDAM-CENTRUM" and "POLITIEK", in this case), and append them to a list.

I'm working with urllib2:

```
reader=CsvUnicodeReader(open("my.csv","r"))
for row in reader:
    url = row[0]
    req=urllib2.Request(url)

```

Is there a way to parse the URL?

Answer: 
If all URLs have similar structure you can simply use

```
url.rsplit('/')[6]

```
You dont really need regular expression here.

```
>>> a=[]
>>> with open('in','r') as f:
...     r=csv.reader(f,delimiter='/')
...     for row in r:
...             a.append(row[6])
... 
>>> a
['AMSTERDAM-CENTRUM', 'POLITIEK']

>>> a=[]
>>> with open('in','r') as f:
...     r=csv.reader(f)
...     for row in r:
...             a.append(row[0].split('/')[6])
... 
>>> a
['AMSTERDAM-CENTRUM', 'POLITIEK']

```