Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
html parser
#8
(Mar-17-2018, 05:55 PM)snippsat Wrote: [quote="tjnichols" pid="42398" dateline="1521306539"]Can you tell me how using the requests module helps me the html? I appreciate your help!
Because it's a better and easier to use than urllib in all parts,eg you get correct encoding back and security is up to date. Your script using Requests,if you look at link i gave you see use of Requests with BeautifulSoup and lxml.
import requests from bs4 import BeautifulSoup url = 'http://www.pythonscraping.com/pages/page1.html' url_get = requests.get(url) soup = BeautifulSoup(url_get.content, 'html.parser') print(soup.find('title').text) print(soup.find('h1').text)
Output:
A Useful Page An Interesting Title
[/quote

Thank you! That makes sense! Let me try itI
Reply


Messages In This Thread
html parser - by tjnichols - Mar-16-2018, 06:13 PM
RE: html parser - by snippsat - Mar-16-2018, 06:16 PM
RE: html parser - by nilamo - Mar-16-2018, 07:31 PM
RE: html parser - by tjnichols - Mar-17-2018, 05:08 PM
RE: html parser - by buran - Mar-16-2018, 07:31 PM
RE: html parser - by metulburr - Mar-16-2018, 07:38 PM
RE: html parser - by snippsat - Mar-17-2018, 05:55 PM
RE: html parser - by tjnichols - Mar-17-2018, 06:28 PM
RE: html parser - by tjnichols - Mar-17-2018, 08:43 PM
RE: html parser - by tjnichols - Mar-17-2018, 11:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,686 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Easy HTML Parser: Validating trs by attributes several tags deep? runswithascript 7 3,632 Aug-14-2020, 10:58 PM
Last Post: runswithascript
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,393 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  Django field model for HTML parser? Drone4four 0 4,174 Nov-15-2017, 02:43 AM
Last Post: Drone4four

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020