Difference between revisions of "Urllib"
Jump to navigation
Jump to search
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | {{lc}} | ||
https://docs.python.org/3/library/urllib.request.html | https://docs.python.org/3/library/urllib.request.html | ||
Line 5: | Line 6: | ||
Adding [[HTTP headers]]: | Adding [[HTTP headers]]: | ||
− | import urllib.request | + | [[import]] urllib.request |
req = urllib.request.Request('http://www.example.com/') | req = urllib.request.Request('http://www.example.com/') | ||
req.add_header('Referer', 'http://www.python.org/') | req.add_header('Referer', 'http://www.python.org/') | ||
Line 12: | Line 13: | ||
r = urllib.request.urlopen(req) | r = urllib.request.urlopen(req) | ||
+ | == Related == | ||
+ | * [[Dependabot]] | ||
+ | == See also == | ||
* {{Python}} | * {{Python}} | ||
+ | |||
+ | [[Category:Python]] |
Latest revision as of 15:21, 1 July 2024
https://docs.python.org/3/library/urllib.request.html
urllib.request
Adding HTTP headers:
import urllib.request req = urllib.request.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 = urllib.request.urlopen(req)
Related[edit]
See also[edit]
- Python, PIP, GIL, Flask, Django, Marshmallow,
def
, logging, Pandas, Numpy, AWS Chalice,import
,from
,tuple
,list
, Python exceptions,virtualenv
,.append
,pytz
,TZ
,print
,python3 -c
,os
, PEP, Python Institute, Methods: Dunder methods, Flake8, Python collections, Function decorators in Python, Click python library, Python module, Flower,kwargs
, Black (Python), Python list structure, Mypy,variables
, Casting,try:
, pydoc, argparse, Anaconda,pyenv, setup.py, python3 --version, python3 --help
, Data Classes, raise
Advertising: