Python Forum
[Learning:bs4, re.search] - RegEx string cutoff
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Learning:bs4, re.search] - RegEx string cutoff
#2
don't use regex to parse html - plain and simple.

obviously this is some <a> tag. so using BeautifulSoup
from bs4 import BeautifulSoup
html = '''<a href="https://newjersey.craigslist.orgparlin-chevrolet-colorado-call/7014860327.html">
<span class="result-price">$18000</span>
</a>'''
soup = BeautifulSoup(html, 'html.parser')
a_tag = soup.find('a')
print(a_tag.get('href'))
also look at our tutorial:
part1
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: [Learning:bs4, re.search] - RegEx string cutoff - by buran - Nov-09-2019, 07:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  string parsing with re.search() delahug 9 3,724 Jun-04-2020, 07:02 PM
Last Post: delahug
  Regex search for string DBS 3 4,612 Feb-06-2017, 11:39 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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