Slicing URL with Python

后端 未结 10 1185
予麋鹿
予麋鹿 2020-12-15 01:17

I am working with a huge list of URL\'s. Just a quick question I have trying to slice a part of the URL out, see below:

http://www.domainname.com/page?CONTEN         


        
10条回答
  •  别那么骄傲
    2020-12-15 01:33

    Another option would be to use the split function, with & as a parameter. That way, you'd extract both the base url and both parameters.

       url.split("&") 
    

    returns a list with

      ['http://www.domainname.com/page?CONTENT_ITEM_ID=1234', 'param2', 'param3']
    

提交回复
热议问题