Python Forum
Having issue with regular expressions
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Having issue with regular expressions
#3
(May-20-2020, 10:39 AM)drcodie Wrote: truncated is in div tags therefore the list of products is empty even if you change it from span. For price the following works:
def web_scrape ():
html = u.urlopen("https://www.amazon.com.au/gp/bestsellers/videogames/")
html_contents = html.read().decode()
htmlPrices = re.compile('sc-price[^\>]*\>(.*?)\<\/span\>')
prices = re.findall(htmlPrices, html_contents)
print(prices)

Don't forget the .*? or you will end up with everything!
If you like this then please like the findall video at https://youtu.be/YCSPhLOMPFM

Please use proper code tags while posting
And also preferably don't post answers; this is homework section
pyzyx3qwerty
"The greatest glory in living lies not in never falling, but in rising every time we fall." - Nelson Mandela
Need help on the forum? Visit help @ python forum
For learning more and more about python, visit Python docs
Reply


Messages In This Thread
Having issue with regular expressions - by azulu - May-19-2020, 04:42 AM
RE: Having issue with regular expressions - by pyzyx3qwerty - May-20-2020, 10:43 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Regular Expressions in Files (find all phone numbers and credit card numbers) Amirsalar 2 4,166 Dec-05-2017, 09:48 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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