wget แบบมี basic authentication

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

พอดีช่วงนี้เขียนใช้เองส่วนตัวเลยเอามาให้ดูเล่นๆ เป็นตัวอย่าง

def wget(url,user,password,realm=''):
    auth = urllib2.HTTPBasicAuthHandler()
    scheme,host,path,t1,t2,t3 = urlparse.urlparse(url)
    auth.add_password(realm,host,user,password)
 
    fd = build_opener(auth).open(url)
    return fd.read()

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น