0

私はこのURLを持っています:

www.domain.com/a/b/c/d,authorised=false.html

そして私はそれをに変換したい

www.domain.com/a/b/c/d.html

私はpython 2.7を使用していることに注意してください。

from urlparse import urlparse

url = "www.domain.com/a/b/c/d,athorised=false.html_i_location=http%3A%2F%2Fwww.domain.com%2Fcms%2Fs%2F0%2Ff416e134-2484-11e4-ae78-00144feabdc0.html%3Fsiteedition%3Dintl&siteedition=intl&_i_referer=http%3A%2F%2Fwww.domain.com%2Fhome%2Fus"

o = urlparse(url)
url = o.hostname + o.path
print url

戻りますが、URLから一部www.domain.com/a/b/c/d,authorised=false.htmlを削除する方法がわかりませんauthorised=false

4

1 に答える 1