A practical manual for the Python urlparse module

Source: Internet
Author: User

#!/usr/bin/env python# -*- coding: utf-8 -*-import urlparsecve =  ' cve-2012-2143 ' path =  '/'  + cve +  '. html ' cveurl =  ' http:// Cve.scap.org.cn/cve-2015-2976.html "     #URLparsedUrl  = urlparse.urlparse (Cveurl)                      #解构为tuple元组print  parsedurlurllist = list (parsedurl)                                   #元组转列表urlList [2] = path                                          #修改列表tup   = tuple (urllist)                                       #列表转元组print   Urllist, tupnewurl = urlparse.urlunparse (TUP)                          #元组重构URLprint   Parsedurl.geturl (), newurl                          #geturl仅适用于urlparse () results, # urlunparse () You can refactor the normal list to a URL

C:\Python27\python.exe c:/users/administrator/pycharmprojects/excelttt/testurllib.py

Parseresult (scheme= ' http ', netloc= ' cve.scap.org.cn ', path= '/cve-2015-2976.html ', params= ', query= ', fragment= ')

[' http ', ' cve.scap.org.cn ', '/cve-2012-2143.html ', ', ', '] (' http ', ' cve.scap.org.cn ', '/cve-2012-2143.html ', ', ', ')

Http://cve.scap.org.cn/CVE-2015-2976.html http://cve.scap.org.cn/CVE-2012-2143.html


This article is from the "Magicpwn" blog, make sure to keep this source http://magicpwn.blog.51cto.com/10497784/1678668

A practical manual for the Python urlparse module

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.