Python Forum
select all the span text with same attribute
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
select all the span text with same attribute
#2
JennyYang

Hi there! What do you think in use the page content and re.search or re.findall function?

Almost like this:

import re
import urllib.request
var_page_content = urllib.request.urlopen("https://urlthatyouneed.com/").read()
result = re.search(var_page_content, '1961') # it will return 1961 in string format
print(result)
Otherwise, use:

import re
import urllib.request
var_page_content = urllib.request.urlopen("https://urlthatyouneed.com/").read()
result = re.findall(r'[0-9]+', var_page_content) # it will return all the numbers in string format
print(result)
Hope it can help you!

Regards,
Martinelli
Reply


Messages In This Thread
RE: select all the span text with same attribute - by Martinelli - Jul-28-2020, 01:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python 3.9 : BeautifulSoup: 'NoneType' object has no attribute 'text' fudgemasterultra 1 8,969 Mar-03-2021, 09:40 AM
Last Post: Larz60+
  trying to scrape a span inside a div using beautifulsoup CompleteNewb 2 9,235 Jan-28-2021, 01:20 PM
Last Post: snippsat
  Scrap a dynamic span hefaz 0 2,722 Mar-07-2020, 02:56 PM
Last Post: hefaz
  Using Python to get attribute text furiousfrodo 2 2,876 Dec-18-2019, 04:18 PM
Last Post: furiousfrodo
  Cannot get contents from ul.li.span.string LLLLLL 8 4,047 Nov-29-2019, 10:30 AM
Last Post: LLLLLL
  How to get visible text of Select Drop down ankitjindalbti 2 2,777 Jun-03-2019, 12:35 AM
Last Post: ankitjindalbti
  Error object has no attribute text hcyeap 3 13,981 May-21-2019, 07:12 AM
Last Post: buran
  BeautifulSoup 'NoneType' object has no attribute 'text' bmccollum 9 14,751 Sep-14-2018, 12:56 PM
Last Post: bmccollum
  selenium click a span tag metulburr 1 22,008 Nov-30-2016, 05:47 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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