SORU
29 NİSAN 2009, ÇARŞAMBA


Urllib2 kullanıcı Aracısı değiştirme.urlopen

Nasıl bir kullanıcı ajan urllib2 varsayılan dışındaki bir web sayfası indirebilirsiniz.urlopen?

CEVAP
4 Mart 2011, Cuma


headers = { 'User-Agent' : 'Mozilla/5.0' }
req = urllib2.Request('www.example.com', None, headers)
html = urllib2.urlopen(req).read()

Ya da, biraz daha kısa

req = urllib2.Request('www.example.com', headers={ 'User-Agent': 'Mozilla/5.0' })
html = urllib2.urlopen(req).read()

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • 2ndfloor91

    2ndfloor91

    17 Kasım 2007
  • Alexander Johnson

    Alexander Jo

    26 Temmuz 2008
  • TheOtherMau5

    TheOtherMau5

    6 Mart 2012