python - Correct Library Usage: requests w/ bs4.BeautifulSoup? -
I just use urllib2 print Only one Getting data from the URL makes it easy, especially if there are redirects, etc. It does not parse the body of urllib2 to switch to
request In the Library Urlib, you use the
BeautifulSoup to drag the html elements using the
findAll (tag = 'element') function, do I use the SunderSub in the same way I request or request that a function simplifies this process?
Import bs4 import from urlib2 import as auspicious BS response = urllib2.urlopen ('http: //stackoverflow.com / ') Soup = BS (reaction) for one in soup. Remove all ('A'): Drag the tag using a [[href]
Import feedback feedback = request.get ('http://stackoverflow.com/'). All ('A'): A [[href]
HTML for you, you should still do this with
BeautifulSoup and for this you should import the second piece of code, and something like this:
soup = BS (response.text)
Comments
Post a Comment