Created
December 13, 2015 22:20
-
-
Save davidcomfort/5791b2ee37865e62050e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
session = requests.Session() | |
headers = {"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit 537.36 (KHTML, like Gecko) Chrome", "Accept":"text/html,application/xhtml+xml,application/xml; q=0.9,image/webp,*/*;q=0.8"} | |
url = "https://www.whatismybrowser.com/developers/what-http-headers-is-my-browser-sending" | |
req = session.get(url, headers=headers) | |
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>text/html,application/xhtml+xml,application/xml; q=0.9,image/webp,*/*;q=0.8</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>Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit 537.36 (KHTML, like Gecko) Chrome</td> | |
</tr> | |
</table>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment