Python 爬虫模块py2x与py3x差异

版权声明:zhaojanc https://blog.csdn.net/qq_38641985/article/details/84562837
try:
    import urllib2#version2.x
except:
    import urllib.request#version3.x
    import urllib.error


try:
    import urllib#version2.x
except:
    import urllib.request#version3.x
    import urllib.error
    import urllib.parse


try:
    import urlparse#version2.x
except:
    import urllib.parse#version3.x

   
try:
    import urllib#.urlopen#version2.x
except:
    import urllib.request#.urlopen#version3.x


try:
    import urllib2#.urlencode#version2.x
    
except:
    import urllib.request#.urlencode#version3.x


try:
    import urllib2#.quote#version2.x
except:
    import urllib.request#.quote#version3.x


try:
    import urllib2#.Request#version2.x
except:
    import urllib.request#.Request#version3.x

try:
    import cookielib#.CookieJar#version2.x
except:
    import http#.CookieJar#version3.x

猜你喜欢

转载自blog.csdn.net/qq_38641985/article/details/84562837
今日推荐