Reputation: 33
I am scraping a website and have come across an issue I can not figure out.
I have extracted the following data from the site:
```
tmp = ['/gourl/2aae9bb244631cf75ac56f4f61384c2dcda0d0e9?redirect=http%3A%2F%2Fwww.facebook.com%2F234343435']
```
How can I save the results of ?redirect.
I have tried this:
```
link = re.search("?redirect=", tmp)
```
and it does not work.
Upvotes: 0
Views: 44
Reputation: 2086
# python3
import urllib.parse
tmp = [
"/gourl/2aae9bb244631cf75ac56f4f61384c2dcda0d0e9?redirect=http%3A%2F%2Fwww.facebook.com%2F234343435"
]
for el in tmp:
url = el.split("?redirect=")[1]
url_decoded = urllib.parse.unquote(url)
print(url_decoded)
Result:
http://www.facebook.com/234343435
Upvotes: 1