Skip to content

Instantly share code, notes, and snippets.

@davidcomfort
Created December 13, 2015 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcomfort/0191fb3c369d1fe42471 to your computer and use it in GitHub Desktop.
Save davidcomfort/0191fb3c369d1fe42471 to your computer and use it in GitHub Desktop.
import requests
from bs4 import BeautifulSoup
session = requests.Session()
url = "https://www.whatismybrowser.com/developers/what-http-headers-is-my-browser-sending"
req = session.get(url)
bsObj = BeautifulSoup(req.text)
print(bsObj.find("table",{"class":"table-striped"}).get_text)
<bound method Tag.get_text of <table class="table table-striped">
<tr>
<th>ACCEPT</th>
<td>*/*</td>
</tr>
<tr>
<th>ACCEPT_ENCODING</th>
<td>gzip, deflate</td>
</tr>
<tr>
<th>HOST</th>
<td>www.whatismybrowser.com</td>
</tr>
<tr>
<th>USER_AGENT</th>
<td>python-requests/2.3.0 CPython/2.7.10 Darwin/15.0.0</td>
</tr>
</table>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment