diff --git a/chapter12/1-headers.py b/chapter12/1-headers.py index 3fe773c..c0315c0 100644 --- a/chapter12/1-headers.py +++ b/chapter12/1-headers.py @@ -2,13 +2,10 @@ 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" +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) \ No newline at end of file +bsObj = BeautifulSoup(req.text, "html.parser") +print(bsObj.find("table",{"class":"table-striped"}).get_text)