1

This is the url that I have https://math.berkeley.edu/~jcalder/126F15/hw1.pdf and I want to get only hw1.pdf of that url.

And, I have used urlparse.urlparse(url).path in the library urlparse and it returned ~jcalder/126F15/hw1.pdf which is not what I wanted.

Hence, can anyone show me how to do it please ?

Ozgur Vatansever
  • 45,449
  • 17
  • 80
  • 115
Alexander
  • 282
  • 1
  • 3
  • 12

1 Answers1

1
urlparse.urlparse(url).path.rsplit("/", 1)[-1]
Ozgur Vatansever
  • 45,449
  • 17
  • 80
  • 115