几乎完全抄袭自http://blog.chinaunix.net/uid-23500957-id-3878767.html
由于
chinaboywg博文中的代码不规整,写这篇是为了给自已看着方便
初学,懂的不多,见谅
#在百度音乐上搜super
import urllib
query = urllib.quote("super")
url = ''+query
response = urllib.urlopen(url)
text = response.read()
print text
print url
print help(urllib.quote)
def url_get():
import urllib
params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
f = urllib.urlopen("%s" % params)
print f.read()
url_get()
#代理IP
import urllib
def url_proxy():
proxies = {'':''} #or
# proxies = {'':'211.167.112.14:80'}
opener = urllib.FancyURLopener(proxies)
f = opener.open("")
print f.read()
def url_post():
import urllib
params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
f = urllib.urlopen("", params)
print f.read()
#多个代理IP
import urllib
def url_proxies():
proxylist = ( '211.167.112.14:80', '210.32.34.115:8080', '115.47.8.39:80', '211.151.181.41:80', '219.239.26.23:80', )
for proxy in proxylist:
proxies = {'': proxy}
opener = urllib.FancyURLopener(proxies)
f = opener.open("")
print f.read()
url_proxies()
代理IP proxylist = ( '211.167.112.14:80', '210.32.34.115:8080', '115.47.8.39:80', '211.151.181.41:80', '219.239.26.23:80', '219.157.200.18:3128', '219.159.105.180:8080', '1.63.18.22:8080', '221.179.173.170:8080', '125.39.66.153:80', '125.39.66.151:80', '61.152.108.187:80', '222.217.99.153:9000', '125.39.66.146:80', '120.132.132.119:8080', '119.7.221.137:82', '117.41.182.188:8080', '202.116.160.89:80', '221.7.145.42:8080', '211.142.236.131:80', '119.7.221.136:80', '211.151.181.41:80', '125.39.66.131:80', '120.132.132.119:8080', '112.5.254.30:80', '106.3.98.82:80', '119.4.250.105:80', '123.235.12.118:8080', '124.240.187.79:80', '182.48.107.219:9000', '122.72.2.180:8080', '119.254.90.18:8080', '124.240.187.80:83', '110.153.9.250:80', '202.202.1.189:80', '58.67.147.205:8080', '111.161.30.228:80', '122.72.76.130:80', '122.72.2.180:80', '202.112.113.7:80', '218.108.85.59:81', '211.144.72.154:80', '119.254.88.53:8080', '121.14.145.132:82', '114.80.149.183:80', '111.161.30.239:80', '182.48.107.219:9000', '122.72.0.28:80', '125.39.68.131:80', '118.244.190.6:80', '120.132.132.119:88', '211.167.112.15:82', '221.2.80.126:8888', '219.137.229.214:3128', '125.39.66.131:80', '61.181.22.157:80', '115.25.216.6:80', '119.7.221.137:82', '221.195.42.195:8080', '119.254.88.53:8080', '219.150.254.158:8080', '113.9.163.101:8080', '222.89.154.14:9000', '114.141.162.53:8080', '218.5.74.199:3128', '61.152.108.187:80', '218.76.159.133:80', '59.34.57.88:8080', '118.244.190.34:80', '59.172.208.189:8080', '116.236.216.116:8080', '111.161.30.233:80', '220.248.237.234:8080', '121.14.145.132:82', '202.114.205.125:8080' )
#用time.sleep()
import urllib
import time
def url_proxies():
proxylist = ( '211.167.112.14:80', '210.32.34.115:8080', '115.47.8.39:80', '211.151.181.41:80', '219.239.26.23:80', )
for proxy in proxylist:
# time.sleep(5)
proxies = {'': proxy}
opener = urllib.FancyURLopener(proxies)
f = opener.open("")
print f.read()
i =0
while i < 100:
time.sleep(5)
url_proxies()
阅读(7115) | 评论(0) | 转发(0) |