添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
  • Bash
  • Cpanel
  • Debian
  • Dokuwiki
  • Eclipse
  • Elastic
  • Extjs
  • Gekko
  • Gentoo
  • Gimp
  • Git
  • Glusterfs
  • Gmail
  • Gnome
  • Google Adsense
  • Google Analytics
  • Google Chrome
  • Google Workspace
  • Html
  • Imagemagick
  • Iphone Ipad
  • Java
  • Javascript
  • Jupyter Notebook
  • Kde
  • Mozilla Firefox
  • Mysql Mariadb
  • Network Security
  • Nodejs
  • Opennebula
  • Pacemaker
  • Phpmyadmin
  • Raspberrypi Os
  • Redhat Centos Fedora
  • Redmine
  • Scrapy
  • Vim
  • Virtualbox
  • Webmaster
  • Wget
  • Launch your preferred Python shell.
    $ ipython3
    Python 3.8.2 (default, Apr 27 2020, 15:53:34)
    Type 'copyright', 'credits' or 'license' for more information
    IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.
  • Import urllib.parse module.
    In [1]: import urllib.parse
  • Parse URL using urlparse function from urllib.parse module.
    In [2]: parsed_url = urllib.parse.urlparse('https://www.example.com/page.html')
  • Print out parsed URL output.
    In [3]: print(parsed_url)
    ParseResult(scheme='https', netloc='www.example.com', path='/page.html', params=//, query=//, fragment=//)
  • Select required output and process accordingly.
    In [4]: print(parsed_url.netloc)
    www.example.com
  • Create a Python script that accepts a URL as parameter and outputs corresponding parsed URL .
    get-host-name-from-url.py
    #!/usr/bin/env python3
    import urllib.parse
    import sys
    url = sys.argv[1]
    parsed_url = urllib.parse.urlparse(url)
    print(parsed_url)
    print("Host name: ", parsed_url.netloc)
  • Run the script from the command with URL as parameter.
    $ python3 get-host-name-from-url.py https://www.example.com/page.html
    ParseResult(scheme='https', netloc='www.example.com', path='/page.html', params=//, query=//, fragment=//)
    Host name:  www.example.com
  •