Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
fcd7d34a
Kaydet (Commit)
fcd7d34a
authored
Haz 01, 2016
tarafından
Martin Panter
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25570: Add example of customizing User-Agent via add_header()
üst
d2b4926f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
urllib2.rst
Doc/howto/urllib2.rst
+2
-0
urllib2.rst
Doc/library/urllib2.rst
+6
-1
No files found.
Doc/howto/urllib2.rst
Dosyayı görüntüle @
fcd7d34a
.. _urllib-howto:
************************************************
HOWTO Fetch Internet Resources Using urllib2
************************************************
...
...
Doc/library/urllib2.rst
Dosyayı görüntüle @
fcd7d34a
...
...
@@ -167,7 +167,7 @@ The following classes are provided:
*headers* should be a dictionary, and will be treated as if :meth:`add_header`
was called with each key and value as arguments. This is often used to "spoof"
the ``User-Agent`` header, which is used by a browser to identify itself --
the ``User-Agent`` header
value
, which is used by a browser to identify itself --
some HTTP servers only allow requests coming from common browsers as opposed
to scripts. For example, Mozilla Firefox may identify itself as ``"Mozilla/5.0
(X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11"``, while :mod:`urllib2`'s
...
...
@@ -950,6 +950,9 @@ HTTPErrorProcessor Objects
Examples
--------
In addition to the examples below, more examples are given in
:ref:`urllib-howto`.
This example gets the python.org main page and displays the first 100 bytes of
it::
...
...
@@ -1016,6 +1019,8 @@ Use the *headers* argument to the :class:`Request` constructor, or::
import urllib2
req = urllib2.Request('http://www.example.com/')
req.add_header('Referer', 'http://www.python.org/')
# Customize the default User-Agent header value:
req.add_header('User-Agent', 'urllib-example/0.1 (Contact: . . .)')
r = urllib2.urlopen(req)
:class:`OpenerDirector` automatically adds a :mailheader:`User-Agent` header to
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment