<p>如果我理解正确的话,你基本上是在问如何使用代理在python中发出url请求?在</p>
<p>如果是,可以按如下方式进行:</p>
<pre><code>import urllib2
import urllib
import random
CAproxies = [{"http":"199.201.122.175:3128", "https":"199.201.122.175:3128"},{"http":"192.99.3.129:3128", "https":"192.99.3.129:3128"},{"http":"192.99.246.101:8118", "https":"192.99.246.101:8118"},{"http":"205.205.129.130:443", "https":"205.205.129.130:443"} ]
proxies = urllib2.ProxyHandler(random.choice(CAproxies))
url = 'https://store.playstation.com/#!/en-ca/movies/the-house/cid=UV0130-NPVA92773_CN-0000000000236063'
request = urllib2.Request(url)
request.add_header("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0")
request.add_header("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8")
opener = urllib2.build_opener(proxies)
urllib2.install_opener(opener)
r = urllib2.urlopen(request, timeout=15)
html = r.read()
</code></pre>
<p>如果你想让服务认为你在使用浏览器,那么标题是很好的,它们通常对机器人有防御能力。你需要用你自己的代理来替换代理地址,这只是一个为了说明目的而发明的代理。在</p>
<p>代理列表可在此处找到,例如:
<a href="http://www.proxy-listen.de/Proxy/Proxyliste.html" rel="nofollow">http://www.proxy-listen.de/Proxy/Proxyliste.html</a>
以防上面给出的代理不起作用。
如果其中一个代理更适合您的特定位置(假设第二个代理最适合您,那么最好将随机选择的代理更改为只选择第二个代理。i、 e</p>
^{pr2}$
<p>卡普生对我最有效。
html的前250个字符:</p>
<pre><code>>>> html[0:250]
'<!DOCTYPE html>\n\n<html class="ctry mobvportA rgba">\n <head>\n <meta http-equiv="x-ua-compatible" content="IE=edge" />\n <meta charset="utf-8"/>\n\n <link rel="dns-prefetch" href="//ajax.googleapis.com">\n <link rel="dns-prefetch" href="//ssl.'
</code></pre>