亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

運行問題!

運行結果剛開始的時候還跟老師的一樣,幾秒后前面幾行就消失了?

正在回答

2 回答

我的也是這樣,哥們你怎么解決的??

0 回復 有任何疑惑可以回復我~

# coding:utf8

import cookielib


print '第一種方法'

import urllib2

url= "http://www.baidu.com"

response = urllib2.urlopen(url)

print response.getcode()

cont = len(response.read())

print cont


print '第二種方法'

request = urllib2.Request(url)

request.add_header("user-agent", "Mozilla/5.0")

response2 = urllib2.urlopen(request)

print response2.getcode()

cont = len(response2.read())

print cont


print "第三種方法"

cj = cookielib.CookieJar()

opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

urllib2.install_opener(opener)

response3 = urllib2.urlopen(url)

print response3.getcode()

print response3.read()

print cj


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Python開發簡單爬蟲
  • 參與學習       227596    人
  • 解答問題       1288    個

本教程帶您解開python爬蟲這門神奇技術的面紗

進入課程

運行問題!

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號