Python Forum
how to convert string soup to raw string ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to convert string soup to raw string ?
#4
I think nilamo ic correct and it is a Beautiful Soup object and not a string.

I Googled "how to search beautiful soup with regx" and found a thread on another forum suggesting Beautiful Soup has a find_all object for regx and the code might look something like the below

import re
>>> soup.find_all(re.compile("(a|div)"))

nope. problems with this too. I'll research more tonight but if anyone knows how to search a beautiful soup object using regx expression let me know. In particular I'm looking for the following on a web page...

my text 1
misc html code
my text 2

If I use Chrome to copy the page source and put it into a string I can use the regx ...
'search' method to do this and return the above in three groups with
'my text 1' in the first, misc html code in the 2nd, and 'my text 2' in the third
or use the
'findall' method to return the three items in a tuple
but this doesn't work with soup.

thanks for any help and some good code examples :-)
Reply


Messages In This Thread
RE: how to convert string soup to raw string ? - by Fran_3 - Aug-16-2017, 01:27 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Soup('A') new_coder_231013 6 2,607 Aug-12-2023, 10:55 AM
Last Post: Pubfonts
  Scrape for html based on url string and output into csv dana 13 5,575 Jan-13-2021, 03:52 PM
Last Post: snippsat
  How to send unicode string encoded in utf-8 in http request in Python MaverinCode 1 32,608 Nov-08-2020, 06:45 AM
Last Post: JaiM
  string parsing with re.search() delahug 9 3,704 Jun-04-2020, 07:02 PM
Last Post: delahug
  URL String with parameters nikoloz 14 6,048 May-15-2020, 08:20 AM
Last Post: DeaD_EyE
  Pandas tuple list returning html string shansaran 0 1,738 Mar-23-2020, 08:44 PM
Last Post: shansaran
  Cannot get contents from ul.li.span.string LLLLLL 8 4,040 Nov-29-2019, 10:30 AM
Last Post: LLLLLL
  [Learning:bs4, re.search] - RegEx string cutoff jarmerfohn 5 3,701 Nov-23-2019, 09:32 AM
Last Post: buran
  ValueError: could not convert string to float Prince_Bhatia 2 4,143 Jan-26-2019, 02:37 PM
Last Post: perfringo
  TypeError: string indices must be integer vanderdecken 1 4,112 Nov-30-2018, 02:24 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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