Python Forum
Beautiful Soup - Title + Paragraph into a text file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Beautiful Soup - Title + Paragraph into a text file
#4
(Jul-14-2018, 12:42 PM)dj99 Wrote: I am trying to put these 2 lines into a text file

<h2 class="Title">section1</h2>
<p class ="mainparagraph">article1</p>
>>> tags = soup.select('.Title, .mainparagraph')
>>> tags
[<h2 class="Title">section1</h2>, <p class="mainparagraph">article1</p>]

>>> for tag in tags:
...     print(tag.text)
...     
section1
article1
Then look how i written to text file in post before.
Reply


Messages In This Thread
RE: Beautiful Soup - Title + Paragraph into a text file - by snippsat - Jul-14-2018, 01:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Soup('A') new_coder_231013 6 2,630 Aug-12-2023, 10:55 AM
Last Post: Pubfonts
  <title> django page title dynamic and other field (not working) lemonred 1 2,140 Nov-04-2021, 08:50 PM
Last Post: lemonred
  Beautiful Soup - access a rating value in a class KatMac 1 3,512 Apr-16-2021, 01:27 PM
Last Post: snippsat
  *Beginner* web scraping/Beautiful Soup help 7ken8 2 2,669 Jan-28-2021, 04:26 PM
Last Post: 7ken8
  Help: Beautiful Soup - Parsing HTML table ironfelix717 2 2,745 Oct-01-2020, 02:19 PM
Last Post: snippsat
  Beautiful Soup (suddenly) doesn't get full webpage html j.crater 8 17,228 Jul-11-2020, 04:31 PM
Last Post: j.crater
  Requests-HTML vs Beautiful Soup - How to Choose? robin73 0 3,857 Jun-23-2020, 02:53 PM
Last Post: robin73
  looking for direction - scrappy, crawler, beautiful soup Sly_Corn 2 2,498 Mar-17-2020, 03:17 PM
Last Post: Sly_Corn
  Beautiful soup truncates results jonesjoz 4 3,975 Mar-09-2020, 06:04 PM
Last Post: jonesjoz
  Getting a specific text inside an html with soup mathieugrimbert 9 16,029 Jul-10-2019, 12:40 PM
Last Post: mathieugrimbert

Forum Jump:

User Panel Messages

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