Python-Requests: get() example

Syntax

requests.get("URL")

requests get() example

import requests

# Get Request
req = requests.get("https://pyonlycode.com")

# Print result
print(req)

Output:

<Response [200]>

 

import requests

# Get Request
req = requests.get("https://pyonlycode.com")

# Print Text result
print(req.text)

Output:

<!DOCTYPE html>
<html lang="en">
<head>

<title>PyOnlyCode | Learn Coding By Code </title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="utf-8" />

<meta name="google-site-verification" content="aTVdZHzzvPCuT3lSpHL-dWjx5L22-9S0qg6uCBi0wes" />
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://pyonlycode.com/images/logo.png">
<meta name="twitter:site" content="">
<meta name="twitter:title" content="PyOnlyCode">
<meta name="twitter:description" content="Learn Coding By Code">

<meta property="og:url" content="https://pyonlycode.com" />
<meta property="og:title" content="PyOnlyCode" />
<meta property="og:description" content="Learn Coding By Code" />

<link rel="icon" type="image/png" href="/static/img/logo.png">
<meta name="google-site-verification" content="zIkKeEj6VcYUCtBRzyZBDlIxfq51iYeowr5AK_D9ytM" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<link rel="preload" as="style" href="/static/css/prism.css">
<link rel="stylesheet" type="text/css" href="/static/css/prism.css" />
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css" />

<link rel="stylesheet" type="text/css" href="/static/css/main.css" />

<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Coda+Caption:[email protected]&display=swap">
<link href="https://fonts.googleapis.com/css2?family=Coda+Caption:[email protected]&display=swap" rel="stylesheet">

</head>
<body>
<header>
<nav class="navbar navbar-expand-md navbar-light bg-light menu">
<div class="container">
<a class="navbar-brand me-auto d-flex" href="/"><img height="80" width="150" alt="logo" src="/static/img/logo.png"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-end" id="navbarSupportedContent">
<ul class="navbar-nav mb-2 mb-lg-0 ml-md-5 d-flex ">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button" data-bs-toggle="dropdown" aria-expanded="false">
Categories
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown1">
<li><a class="dropdown-item" href="/category/python/" title="Python">Python</a></li>
<li><a class="dropdown-item" href="/category/beautifulsoup/" title="Beautifulsoup">Beautifulsoup</a></li>
<li><a class="dropdown-item" href="/category/pytrends/" title="pytrends">pytrends</a></li>
</ul>
</li>
<li class="nav-item">
<a class="nav-link" href="#/about-us">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#/contact-us">Contact</a>
</li>
</ul>
<div class="d-flex">
<input id="s" class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success">Search</button>
</div>
</div>
</div>
</nav>
</header>
<div class="page container" role="main">
<h1>PyOnlyCode | Learn Coding By Code</h1>
<div class="articles">
<div class="row">
<div class="col-md-6">
<div class="article-list">
<a href="/post/solution-modulenotfounderror-nameerror-name-validate_netmask-is-not-defined/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Solution: ModuleNotFoundError: NameError: name &#39;validate_netmask&#39; is not defined"></a>
<a href="/post/solution-modulenotfounderror-nameerror-name-validate_netmask-is-not-defined/"><h2 class="card-title">Solution: ModuleNotFoundError: NameError: name &#39;validate_netmask&#39; is not defined</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/python-iptools-validate_netmask-example/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Python-Iptools: validate_netmask Example"></a>
<a href="/post/python-iptools-validate_netmask-example/"><h2 class="card-title">Python-Iptools: validate_netmask Example</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/iptools-ipv4validate_ip-example/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Iptools: ipv4.validate_ip Example"></a>
<a href="/post/iptools-ipv4validate_ip-example/"><h2 class="card-title">Iptools: ipv4.validate_ip Example</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/iptools-ipv4ip2hex-example/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Iptools: ipv4.ip2hex Example"></a>
<a href="/post/iptools-ipv4ip2hex-example/"><h2 class="card-title">Iptools: ipv4.ip2hex Example</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/solution-modulenotfounderror-no-module-named-iptools/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Solution: ModuleNotFoundError: No module named &#39;iptools&#39;"></a>
<a href="/post/solution-modulenotfounderror-no-module-named-iptools/"><h2 class="card-title">Solution: ModuleNotFoundError: No module named &#39;iptools&#39;</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/solution-nameerror-name-slugify-is-not-defined/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Solution: NameError: name &#39;slugify&#39; is not defined"></a>
<a href="/post/solution-nameerror-name-slugify-is-not-defined/"><h2 class="card-title">Solution: NameError: name &#39;slugify&#39; is not defined</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/python-slugify-separator-example/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Python: slugify separator example"></a>
<a href="/post/python-slugify-separator-example/"><h2 class="card-title">Python: slugify separator example</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/python-slugify-max_length-example/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Python: slugify max_length example"></a>
<a href="/post/python-slugify-max_length-example/"><h2 class="card-title">Python: slugify max_length example</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/solution-nameerror-name-speedtest-is-not-defined/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="Solution: NameError: name &#39;speedtest&#39; is not defined"></a>
<a href="/post/solution-nameerror-name-speedtest-is-not-defined/"><h2 class="card-title">Solution: NameError: name &#39;speedtest&#39; is not defined</h2></a>
</div>
</div>
<div class="col-md-6">
<div class="article-list">
<a href="/post/python-speedtest-cli-example/"><img class="card-img-top lazy" src="/media/cover/py.jpg" alt="python: Speedtest-cli Example"></a>
<a href="/post/python-speedtest-cli-example/"><h2 class="card-title">python: Speedtest-cli Example</h2></a>
</div>
</div>
</div>
</div>
<nav>
<ul class="pagination justify-content-center">
<li class="page-item disabled">
<a class="page-link" href="#">Previous</a>
</li>
<li class="page-item active">
<span class="page-link">
<span class="sr-only">1</span>
</span>
</li>
<li class="page-item"><a class="page-link" href="?page=2">2</a></li>
<li class="page-item"><a class="page-link" href="?page=3">3</a></li>
<li class="page-item"><a class="page-link" href="?page=4">4</a></li>
<li class="page-item"><a class="page-link" href="?page=5">5</a></li>
<li class="page-item"><a class="page-link" href="?page=6">6</a></li>
<li class="page-item disabled">
<a class="page-link" href="#">Next</a>
</li>
</ul>
</nav>

<script type="application/ld+json">
{
  "@context": "https://schema.org/",
  "@type": "home",
  "name": "PyOnlyCode | Learn Coding By Code",
  "author": "Sd Bllm",
  "description": "PyOnlyCode | Learn Coding By Code",
  "prepTime": "PT30M",
  "totalTime": "PT1H",
  "recipeYield": "8",
  "url": "https://pyonlycode.com",
 "datePublished": "15-09-2021",
 "dateModified": "15-09-2021",
 "headline": "PyOnlyCode | Learn Coding By Code",
"itemListElement": {
                        "@type": "home",
                        "position": 1,
                        "text": "PyOnlyCode | Learn Coding By Code"
                    },
 "foundingDate": "2021"

}
</script>
<footer>
<p>© 2021</p>
</footer>
</div>
<script src="/static/js/prism.js"></script>
<script src="/static/js/bootstrap.bundle.min.js"></script>
<script src="/static/js/main.js"></script>
</body>
</html>