you can import bs4 instead of BeautifulSoup. Since bs4 is a built-in module, no additional installation is required.
from bs4 import BeautifulSoup import re doc = ['<html><head><title>Page title</title></head>', '<body><p id="firstpara" align="center">This is paragraph <b>one</b>.', '<p id="secondpara" align="blah">This is paragraph <b>two</b>.', '</html>'] soup = BeautifulSoup(''.join(doc)) print soup.prettify()
If you want to query using the query module. The request uses urllib
, requests
modules. but I personally recommend using the requests
module instead of urllib
install the module to use:
$ pip install requests
Here's how to use the query module:
import requests as rq res = rq.get('http://www.example.com') print(res.content) print(res.status_code)
λ©κ° -mung 06 Oct '17 at 4:05 2017-10-06 04:05
source share