Python urllib2.Request Instagram 无法读取标题回复
Python urllib2.Request title response unreadable for instagram
我有以下代码:
def check_proxy(input_queue):
while 1:
prx = input_queue.get()
try:
proxy_handler = urllib2.ProxyHandler({'http': prx})
opener = urllib2.build_opener(proxy_handler)
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib2.install_opener(opener)
req = urllib2.Request("http://www.google.com")
sock = urllib2.urlopen(req, timeout=7)
rs = sock.read(1000)
if '<title>Google</title>' in rs:
print '[OK]', prx
input_queue.task_done()
我已将检查 Google.com 更改为 instagram.com
并且我已将标题更改为 Instagram
但由于某些原因它不起作用。
我已经检查了 "print rs" 的 Instagram。并获得了这个称号:
<title>
Instagram
</title>
只是想知道如何让它检查 https://www.instagram.com 而不是 google.com
谢谢
与 Instagram HTML 中的标题匹配的字符串应为 '<title>\nInstagram\n<title>
。 Google 的 HTML 中没有换行符,但 Instagram 有。
我有以下代码:
def check_proxy(input_queue):
while 1:
prx = input_queue.get()
try:
proxy_handler = urllib2.ProxyHandler({'http': prx})
opener = urllib2.build_opener(proxy_handler)
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
urllib2.install_opener(opener)
req = urllib2.Request("http://www.google.com")
sock = urllib2.urlopen(req, timeout=7)
rs = sock.read(1000)
if '<title>Google</title>' in rs:
print '[OK]', prx
input_queue.task_done()
我已将检查 Google.com 更改为 instagram.com
并且我已将标题更改为 Instagram
但由于某些原因它不起作用。
我已经检查了 "print rs" 的 Instagram。并获得了这个称号:
<title>
Instagram
</title>
只是想知道如何让它检查 https://www.instagram.com 而不是 google.com
谢谢
与 Instagram HTML 中的标题匹配的字符串应为 '<title>\nInstagram\n<title>
。 Google 的 HTML 中没有换行符,但 Instagram 有。