Python Forum

Full Version: Help, simply grab web content
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import requests
from bs4 import BeautifulSoup
res=requests.get('http://127.0.0.1:8887/4.9/ActualCombat.html')
soup=BeautifulSoup(res.text,'html.parser')
print(soup.prettify())

test=soup.select('')#Fill in here, you can get the two characters of ‘home’ in the webpage
print(test)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>nav</title>
<script src="js/jquery-3.3.1.js"></script>
<link rel="stylesheet" href="css/bootstrap.css">
<script src="js/bootstrap.js"></script>
<style>
span{
margin-left: 6px;
}
img{
margin-left: 2%;
float: left;
width:130px;

}

</style>
</head>
<body>
<div id="test">
<nav class="nav navbar-inverse" role="navigation">
<div>
<img class="navbar-header" src="images/logo.png">
</div>
<ul class="nav navbar-nav">
<li><a class="active" href="#">home</a></li>
</ul>
</nav>
</div>
</body>
</html>

solved