-8

How can I get https://onion-rip.de from

https://onion-rip.de/data/images/9d5faef5c26f69546f8/68c8a2a5fe0a9c5c221a2bb.jpg

and replace with https://test.de. Output should be:

https://test.de/data/images/9d5faef5c26f69546f8/68c8a2a5fe0a9c5c221a2bb.jpg

Is any special function in Python for this?

user4812479812
  • 583
  • 1
  • 6
  • 13
  • 2
    Basic Python and there's examples all over the internet. Try `str.replace(x, y)` for instance. Almost any language has a string replacement function. – Torxed May 25 '16 at 08:20
  • 1
    Please, do not ask questions whose answer can be found with a single internet search or simply by looking at the documentation. – T. Claverie May 25 '16 at 08:21
  • show what you have tried first. You'll get help from there ... – quemeraisc May 25 '16 at 08:22
  • 1
    Honestly, do not ask this kind of questions here. The answer is so easily accesible by Googling. Take a look at Python's documentation about [string](https://docs.python.org/2/library/string.html) and [urlparse](https://docs.python.org/2/library/urlparse.html). – kazbeel May 25 '16 at 08:25

2 Answers2

2

Use Python's .replace() like in the following example:

x = "Hello world!"
y = x.replace("Hello", "Bye")
print y #Will print out "Bye World!"
Bubble Hacker
  • 6,425
  • 1
  • 17
  • 24
1

You can use Python's replace() method to do this:

oldUrl = 'https://onion-rip.de/data/images/9d5faef5c26f69546f8/68c8a2a5fe0a9c5c221a2bb.jpg'
newUrl = oldUrl.replace('https://onion-rip.de', 'https://test.de')
print(newUrl)
Ainz23
  • 56
  • 1
  • 4