Question: I'm trying to to fetch a page that has many urls and other stuff all in just one line in a plain text like

```
"link_url":"http://www.example.com/link1?site=web","mobile_link_url":"http://m.example.com/episode/link1?site=web" link_url":"http://www.example.com/link2?site=web","mobile_link_url":"http://m.example.com/episode/link2?site=web"

```

i tired 

```
import re
import requests as req

response = req.get("http://api.example.com/?callback=jQuery112")

content = response.text

```

print content will give me the "link\_url": output 
but i need to find 

```
http://www.example.com/link1?site=web
http://www.example.com/link2?site=web

```

and output only link1 and link2 to a file like 

```
link1
link2
link3

```

Answer: 
If this is a JSON api then you can use `response.json()` to get a python dictionary, as `.text` will give you the response as one long string.

You also do not need to use regex for something so simple, python comes with a url parser out of the box.

So provided your response is something like

```
[
  {
    "link_url": "http://www.example.com/link1?site=web",
    "mobile_link_url": "http://m.example.com/episode/link1?site=web"
  },
  {
    "link_url": "http://www.example.com/link2?site=web",
    "mobile_link_url": "http://m.example.com/episode/link2?site=web"
  }
]

```

(doesn't matter if IRL it's one line, as long as it's valid JSON)

You can iterate the results as a dictionary, then use urlparse to get specific components of your urls:

```py
from urllib.parse import urlparse
import requests

response = requests.get("http://api.example.com/?callback=jQuery112")

for urls in response.json():
    print(urlparse(url["link_url"]).path.rsplit('/', 1)[-1])

```

`urlparse(...).path` will return the path of your url only, eg. `episode/link1`, and we then we just get the last segment of that with `rsplit` to just get `link1`, `link2` etc.
try

```
urls=""" "link_url":"http://www.example.com/link1?site=web","mobile_link_url":"http://m.example.com/episode/link1?site=web" link_url":"http://www.example.com/link2?site=web","mobile_link_url":"http://m.example.com/episode/link2?site=web" """
re.findall(r'"http://www[^"]+"',urls)

```